mainwindow.cpp 189 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/***************************************************************************
 *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@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) any later version.                                   *
 *                                                                         *
 *   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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
 ***************************************************************************/

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
20
#include "mainwindow.h"
21
#include "assets/assetpanel.hpp"
22
#include "bin/clipcreator.hpp"
23
#include "bin/generators/generators.h"
24
#include "bin/model/subtitlemodel.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
25
#include "bin/projectclip.h"
26
27
#include "bin/projectfolder.h"
#include "bin/projectitemmodel.h"
Nicolas Carion's avatar
Nicolas Carion committed
28
#include "core.h"
29
#include "dialogs/clipcreationdialog.h"
Nicolas Carion's avatar
Nicolas Carion committed
30
31
32
#include "dialogs/kdenlivesettingsdialog.h"
#include "dialogs/renderwidget.h"
#include "dialogs/wizard.h"
33
#include "dialogs/subtitleedit.h"
34
#include "doc/docundostack.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
35
#include "doc/kdenlivedoc.h"
36
#include "dockareaorientationmanager.h"
37
#include "effects/effectlist/view/effectlistwidget.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
38
39
#include "effectslist/effectbasket.h"
#include "hidetitlebars.h"
40
41
#include "jobs/jobmanager.h"
#include "jobs/scenesplitjob.hpp"
42
#include "jobs/speedjob.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
43
#include "jobs/stabilizejob.hpp"
44
#include "jobs/transcodeclipjob.h"
Nicolas Carion's avatar
Nicolas Carion committed
45
46
47
#include "kdenlivesettings.h"
#include "layoutmanagement.h"
#include "library/librarywidget.h"
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
48
#include "audiomixer/mixermanager.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
49
50
51
52
53
54
#include "mainwindowadaptor.h"
#include "mltconnection.h"
#include "mltcontroller/clipcontroller.h"
#include "monitor/monitor.h"
#include "monitor/monitormanager.h"
#include "monitor/scopes/audiographspectrum.h"
55
#include "onlineresources/resourcewidget.hpp"
Nicolas Carion's avatar
linting    
Nicolas Carion committed
56
#include "profiles/profilemodel.hpp"
Vincent Pinon's avatar
Vincent Pinon committed
57
#include "project/cliptranscode.h"
Vincent Pinon's avatar
Vincent Pinon committed
58
#include "project/dialogs/archivewidget.h"
Nicolas Carion's avatar
Nicolas Carion committed
59
60
#include "project/dialogs/projectsettings.h"
#include "project/projectcommands.h"
Till Theato's avatar
Till Theato committed
61
#include "project/projectmanager.h"
Nicolas Carion's avatar
Nicolas Carion committed
62
#include "scopes/scopemanager.h"
Nicolas Carion's avatar
linting    
Nicolas Carion committed
63
#include "timeline2/view/timelinecontroller.h"
64
#include "timeline2/view/timelinetabs.hpp"
65
#include "timeline2/view/timelinewidget.h"
Nicolas Carion's avatar
Nicolas Carion committed
66
67
68
#include "titler/titlewidget.h"
#include "transitions/transitionlist/view/transitionlistwidget.hpp"
#include "transitions/transitionsrepository.hpp"
69
//#include "utils/resourcewidget_old.h" //TODO
Nicolas Carion's avatar
Nicolas Carion committed
70
#include "utils/thememanager.h"
Vincent Pinon's avatar
Vincent Pinon committed
71
#include "utils/otioconvertions.h"
72
#include "lib/localeHandling.h"
73
#include "profiles/profilerepository.hpp"
74
75
#include "widgets/progressbutton.h"
#include <config-kdenlive.h>
76
#include "dialogs/textbasededit.h"
77
#include "project/dialogs/temporarydata.h"
78

79
80
81
#ifdef USE_JOGSHUTTLE
#include "jogshuttle/jogmanager.h"
#endif
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
82

83
#include <KActionCategory>
Nicolas Carion's avatar
Nicolas Carion committed
84
#include <KActionCollection>
85
#include <KActionMenu>
Nicolas Carion's avatar
Nicolas Carion committed
86
87
#include <KColorScheme>
#include <KColorSchemeManager>
88
#include <KConfigDialog>
Nicolas Carion's avatar
Nicolas Carion committed
89
90
#include <KDualAction>
#include <KEditToolBar>
91
#include <KIconTheme>
Nicolas Carion's avatar
Nicolas Carion committed
92
93
#include <KMessageBox>
#include <KNotifyConfigWidget>
94
#include <KRecentDirs>
Nicolas Carion's avatar
Nicolas Carion committed
95
96
97
98
99
#include <KShortcutsDialog>
#include <KStandardAction>
#include <KToolBar>
#include <KXMLGUIFactory>
#include <klocalizedstring.h>
100
101
#include <kns3/downloaddialog.h>
#include <kns3/knewstuffaction.h>
Nicolas Carion's avatar
Nicolas Carion committed
102
#include <ktogglefullscreenaction.h>
103

Laurent Montel's avatar
Laurent Montel committed
104
#include "kdenlive_debug.h"
Nicolas Carion's avatar
Nicolas Carion committed
105
106
107
108
#include <QAction>
#include <QFileDialog>
#include <QMenu>
#include <QMenuBar>
109
#include <QStatusBar>
Nicolas Carion's avatar
Nicolas Carion committed
110
#include <QStyleFactory>
111
#include <QUndoGroup>
Vincent Pinon's avatar
Vincent Pinon committed
112
113
114
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
115
#include <QScreen>
Nicolas Carion's avatar
Nicolas Carion committed
116
117
#include <QStandardPaths>
#include <QVBoxLayout>
118

119
static const char version[] = KDENLIVE_VERSION;
Nicolas Carion's avatar
Nicolas Carion committed
120
namespace Mlt {
121
class Producer;
Laurent Montel's avatar
Laurent Montel committed
122
}
123

Laurent Montel's avatar
Laurent Montel committed
124
125
QMap<QString, QImage> MainWindow::m_lumacache;
QMap<QString, QStringList> MainWindow::m_lumaFiles;
126

127
/*static bool sortByNames(const QPair<QString, QAction *> &a, const QPair<QString, QAction*> &b)
128
129
{
    return a.first < b.first;
130
}*/
131

Yuri Chornoivan's avatar
Yuri Chornoivan committed
132
// determine the default KDE style as defined BY THE USER
133
// (as opposed to whatever style KDE considers default)
Laurent Montel's avatar
Laurent Montel committed
134
static QString defaultStyle(const char *fallback = nullptr)
135
136
137
138
139
140
{
    KSharedConfigPtr kdeGlobals = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals);
    KConfigGroup cg(kdeGlobals, "KDE");
    return cg.readEntry("widgetStyle", fallback);
}

Nicolas Carion's avatar
Nicolas Carion committed
141
MainWindow::MainWindow(QWidget *parent)
142
    : KXmlGuiWindow(parent)
143
{
144
145
}

146
void MainWindow::init(const QString &mltPath)
147
{
148
    QString desktopStyle = QApplication::style()->objectName();
149
150
151
152
153
    // Load themes
    auto themeManager = new ThemeManager(actionCollection());
    actionCollection()->addAction(QStringLiteral("themes_menu"), themeManager);
    connect(themeManager, &ThemeManager::themeChanged, this, &MainWindow::slotThemeChanged);

154
155
156
157
    if (!KdenliveSettings::widgetstyle().isEmpty() && QString::compare(desktopStyle, KdenliveSettings::widgetstyle(), Qt::CaseInsensitive) != 0) {
        // User wants a custom widget style, init
        doChangeStyle();
    }
Nicolas Carion's avatar
Nicolas Carion committed
158

159
    // Widget themes for non KDE users
Laurent Montel's avatar
Laurent Montel committed
160
    KActionMenu *stylesAction = new KActionMenu(i18n("Style"), this);
Nicolas Carion's avatar
Nicolas Carion committed
161
    auto *stylesGroup = new QActionGroup(stylesAction);
162

163
164
    // GTK theme does not work well with Kdenlive, and does not support color theming, so avoid it
    QStringList availableStyles = QStyleFactory::keys();
165
166
    if (KdenliveSettings::widgetstyle().isEmpty()) {
        // First run
167
        QStringList incompatibleStyles = {QStringLiteral("GTK+"), QStringLiteral("windowsvista"), QStringLiteral("Windows")};
168

169
        if (incompatibleStyles.contains(desktopStyle, Qt::CaseInsensitive)) {
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
170
            if (availableStyles.contains(QStringLiteral("breeze"), Qt::CaseInsensitive)) {
171
172
                // Auto switch to Breeze theme
                KdenliveSettings::setWidgetstyle(QStringLiteral("Breeze"));
173
		QApplication::setStyle(QStyleFactory::create(QStringLiteral("Breeze")));
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
174
            } else if (availableStyles.contains(QStringLiteral("fusion"), Qt::CaseInsensitive)) {
175
                KdenliveSettings::setWidgetstyle(QStringLiteral("Fusion"));
176
		QApplication::setStyle(QStyleFactory::create(QStringLiteral("Fusion")));
177
            }
178
179
        } else {
            KdenliveSettings::setWidgetstyle(QStringLiteral("Default"));
180
181
182
        }
    }

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
183
184
    // Add default style action
    QAction *defaultStyle = new QAction(i18n("Default"), stylesGroup);
185
    defaultStyle->setData(QStringLiteral("Default"));
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
186
187
    defaultStyle->setCheckable(true);
    stylesAction->addAction(defaultStyle);
188
    if (KdenliveSettings::widgetstyle() == QLatin1String("Default") || KdenliveSettings::widgetstyle().isEmpty()) {
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
189
190
191
        defaultStyle->setChecked(true);
    }

Vincent Pinon's avatar
Vincent Pinon committed
192
    for (const QString &style : qAsConst(availableStyles)) {
Nicolas Carion's avatar
Nicolas Carion committed
193
        auto *a = new QAction(style, stylesGroup);
194
195
        a->setCheckable(true);
        a->setData(style);
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
196
197
198
        if (KdenliveSettings::widgetstyle() == style) {
            a->setChecked(true);
        }
199
200
201
        stylesAction->addAction(a);
    }
    connect(stylesGroup, &QActionGroup::triggered, this, &MainWindow::slotChangeStyle);
Nicolas Carion's avatar
Nicolas Carion committed
202
    // QIcon::setThemeSearchPaths(QStringList() <<QStringLiteral(":/icons/"));
203
204

    new RenderingAdaptor(this);
205
    QString defaultProfile = KdenliveSettings::default_profile();
206
207
208
    
    // Initialise MLT connection
    MltConnection::construct(mltPath);
209
    pCore->setCurrentProfile(defaultProfile.isEmpty() ? ProjectManager::getDefaultProjectFormat() : defaultProfile);
210
    m_commandStack = new QUndoGroup();
211
212

    // If using a custom profile, make sure the file exists or fallback to default
213
214
    QString currentProfilePath = pCore->getCurrentProfile()->path();
    if (currentProfilePath.startsWith(QLatin1Char('/')) && !QFile::exists(currentProfilePath)) {
215
        KMessageBox::sorry(this, i18n("Cannot find your default profile, switching to ATSC 1080p 25"));
216
        pCore->setCurrentProfile(QStringLiteral("atsc_1080p_25"));
Laurent Montel's avatar
Laurent Montel committed
217
        KdenliveSettings::setDefault_profile(QStringLiteral("atsc_1080p_25"));
218
    }
219
    m_gpuAllowed = EffectsRepository::get()->hasInternalEffect(QStringLiteral("glsl.manager"));
220

221
    m_shortcutRemoveFocus = new QShortcut(QKeySequence(QStringLiteral("Esc")), this);
Laurent Montel's avatar
Laurent Montel committed
222
    connect(m_shortcutRemoveFocus, &QShortcut::activated, this, &MainWindow::slotRemoveFocus);
Simon Eugster's avatar
Simon Eugster committed
223

224
    /// Add Widgets
225
    setDockOptions(dockOptions() | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
226
    setDockOptions(dockOptions() | QMainWindow::GroupedDragging);
Vincent Pinon's avatar
Vincent Pinon committed
227
    setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::TabPosition(KdenliveSettings::tabposition()));
228
    m_timelineToolBar = toolBar(QStringLiteral("timelineToolBar"));
229
    m_timelineToolBarContainer = new TimelineContainer(this);
Nicolas Carion's avatar
Nicolas Carion committed
230
    auto *ctnLay = new QVBoxLayout;
231
232
    ctnLay->setSpacing(0);
    ctnLay->setContentsMargins(0, 0, 0, 0);
233
    m_timelineToolBarContainer->setLayout(ctnLay);
234
235
236
237
    QFrame *topFrame = new QFrame(this);
    topFrame->setFrameShape(QFrame::HLine);
    topFrame->setFixedHeight(1);
    topFrame->setLineWidth(1);
Vincent Pinon's avatar
Vincent Pinon committed
238
    connect(this, &MainWindow::focusTimeline, this, [topFrame](bool focus, bool highlight) {
239
240
241
242
243
244
245
246
247
248
249
250
251
252
        if (focus) {
            KColorScheme scheme(QApplication::palette().currentColorGroup(), KColorScheme::Tooltip);
            if (highlight) {
                QColor col = scheme.decoration(KColorScheme::HoverColor).color();
                topFrame->setStyleSheet(QString("QFrame {border: 1px solid rgba(%1,%2,%3,70)}").arg(col.red()).arg(col.green()).arg(col.blue()));
            } else {
                QColor col = scheme.decoration(KColorScheme::FocusColor).color();
                topFrame->setStyleSheet(QString("QFrame {border: 1px solid rgba(%1,%2,%3,100)}").arg(col.red()).arg(col.green()).arg(col.blue()));
            }
        } else {
            topFrame->setStyleSheet(QString());
        }
    });
    ctnLay->addWidget(topFrame);
253
    ctnLay->addWidget(m_timelineToolBar);
254
255
256
257
    KSharedConfigPtr config = KSharedConfig::openConfig();
    KConfigGroup mainConfig(config, QStringLiteral("MainWindow"));
    KConfigGroup tbGroup(&mainConfig, QStringLiteral("Toolbar timelineToolBar"));
    m_timelineToolBar->applySettings(tbGroup);
258
259
260
261
262
    QFrame *fr = new QFrame(this);
    fr->setFrameShape(QFrame::HLine);
    fr->setMaximumHeight(1);
    fr->setLineWidth(1);
    ctnLay->addWidget(fr);
263
    setupActions();
264
    auto *layoutManager = new LayoutManagement(this);
265

Laurent Montel's avatar
Laurent Montel committed
266
    QDockWidget *libraryDock = addDock(i18n("Library"), QStringLiteral("library"), pCore->library());
267
    QDockWidget *subtitlesDock = addDock(i18n("Subtitles"), QStringLiteral("Subtitles"), pCore->subtitleWidget());
268
    QDockWidget *textEditingDock = addDock(i18n("Text Edit"), QStringLiteral("textedit"), pCore->textEditWidget());
Simon Eugster's avatar
Simon Eugster committed
269

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
270
    m_clipMonitor = new Monitor(Kdenlive::ClipMonitor, pCore->monitorManager(), this);
271
    pCore->bin()->setMonitor(m_clipMonitor);
272
273
    connect(m_clipMonitor, &Monitor::addMarker, this, &MainWindow::slotAddMarkerGuideQuickly);
    connect(m_clipMonitor, &Monitor::deleteMarker, this, &MainWindow::slotDeleteClipMarker);
274
275
    connect(m_clipMonitor, &Monitor::seekToPreviousSnap, this, &MainWindow::slotSnapRewind);
    connect(m_clipMonitor, &Monitor::seekToNextSnap, this, &MainWindow::slotSnapForward);
276

277
    connect(pCore->bin(), &Bin::findInTimeline, this, &MainWindow::slotClipInTimeline, Qt::DirectConnection);
278
    connect(pCore->bin(), &Bin::setupTargets, this, [&] (bool hasVideo, QMap <int, QString> audioStreams) {
279
            getCurrentTimeline()->controller()->setTargetTracks(hasVideo, audioStreams);
280
281
        }
    );
282

Nicolas Carion's avatar
Nicolas Carion committed
283
    // TODO deprecated, replace with Bin methods if necessary
284
    /*connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
285
    connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
Laurent Montel's avatar
Laurent Montel committed
286
    connect(m_projectList, SIGNAL(updateProfile(QString)), this, SLOT(slotUpdateProjectProfile(QString)));
287
    connect(m_projectList, SIGNAL(refreshClip(QString,bool)), pCore->monitorManager(), SLOT(slotRefreshCurrentMonitor(QString)));
288
    connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));*/
289

Laurent Montel's avatar
Laurent Montel committed
290
    connect(m_clipMonitor, &Monitor::passKeyPress, this, &MainWindow::triggerKey);
291

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
292
    m_projectMonitor = new Monitor(Kdenlive::ProjectMonitor, pCore->monitorManager(), this);
Laurent Montel's avatar
Laurent Montel committed
293
    connect(m_projectMonitor, &Monitor::passKeyPress, this, &MainWindow::triggerKey);
294
    connect(m_projectMonitor, &Monitor::addMarker, this, &MainWindow::slotAddMarkerGuideQuickly);
295
    connect(m_projectMonitor, &Monitor::deleteMarker, this, &MainWindow::slotDeleteGuide);
296
297
    connect(m_projectMonitor, &Monitor::seekToPreviousSnap, this, &MainWindow::slotSnapRewind);
    connect(m_projectMonitor, &Monitor::seekToNextSnap, this, &MainWindow::slotSnapForward);
Vincent Pinon's avatar
Vincent Pinon committed
298
    connect(m_loopClip, &QAction::triggered, this, [&]() {
299
300
301
        QPoint inOut = getMainTimeline()->controller()->selectionInOut();
        m_projectMonitor->slotLoopClip(inOut);
    });
302

303
    pCore->monitorManager()->initMonitors(m_clipMonitor, m_projectMonitor);
304
    connect(m_clipMonitor, &Monitor::addMasterEffect, pCore->bin(), &Bin::slotAddEffect);
305

306
307
    m_timelineTabs = new TimelineTabs(this);
    ctnLay->addWidget(m_timelineTabs);
308
    setCentralWidget(m_timelineToolBarContainer);
309

310
311
    // Screen grab widget
    QWidget *grabWidget = new QWidget(this);
312
    auto *grabLayout = new QVBoxLayout;
313
    grabWidget->setLayout(grabLayout);
314
    auto *recToolbar = new QToolBar(grabWidget);
315
316
    grabLayout->addWidget(recToolbar);
    grabLayout->addStretch(10);
317
    // Check number of monitors for FFmpeg screen capture
Vincent Pinon's avatar
Vincent Pinon committed
318
    int screens = QApplication::screens().count();
319
    if (screens > 1) {
320
        auto *screenCombo = new QComboBox(recToolbar);
321
322
323
324
325
326
327
328
        for (int ix = 0; ix < screens; ix++) {
            screenCombo->addItem(i18n("Monitor %1", ix));
        }
        connect(screenCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), m_clipMonitor, &Monitor::slotSetScreen);
        recToolbar->addWidget(screenCombo);
        // Update screen grab monitor choice in case we changed from fullscreen
        screenCombo->setEnabled(KdenliveSettings::grab_capture_type() == 0);
    }
329
330
331
332
333
334
    QAction *recAction = m_clipMonitor->recAction();
    addAction(QStringLiteral("screengrab_record"), recAction);
    recToolbar->addAction(recAction);
    QAction *recConfig = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure Recording"), this);
    recToolbar->addAction(recConfig);
    connect(recConfig, &QAction::triggered, [&]() {
Vincent Pinon's avatar
Vincent Pinon committed
335
        emit pCore->showConfigDialog(4, 0);
336
337
    });
    QDockWidget *screenGrabDock = addDock(i18n("Screen Grab"), QStringLiteral("screengrab"), grabWidget);
338

339
340
    // Audio spectrum scope
    m_audioSpectrum = new AudioGraphSpectrum(pCore->monitorManager());
Laurent Montel's avatar
Laurent Montel committed
341
    QDockWidget *spectrumDock = addDock(i18n("Audio Spectrum"), QStringLiteral("audiospectrum"), m_audioSpectrum);
Vincent Pinon's avatar
Vincent Pinon committed
342
    connect(spectrumDock, &QDockWidget::visibilityChanged, this, [&](bool visible) {
343
344
        m_audioSpectrum->dockVisible(visible);
    });
345
346
347
348
349
350
351
352
    
    // Project bin
    m_projectBinDock = addDock(i18n("Project Bin"), QStringLiteral("project_bin"), pCore->bin());
    
    // Media browser widget
    QDockWidget* clipDockWidget = addDock(i18n("Media Browser"), QStringLiteral("bin_clip"), pCore->bin()->getWidget());
    pCore->bin()->dockWidgetInit(clipDockWidget);

353
    // Online resources widget
354
    auto *onlineResources = new ResourceWidget(this);
355
    m_onlineResourcesDock = addDock(i18n("Online Resources"), QStringLiteral("onlineresources"), onlineResources);
356
357
    connect(onlineResources, &ResourceWidget::previewClip, [&](const QString &path, const QString &title) {
        m_clipMonitor->slotPreviewResource(path, title);
358
359
360
        m_clipMonitorDock->show();
        m_clipMonitorDock->raise();
    });
361

362
    connect(onlineResources, &ResourceWidget::addClip, this, &MainWindow::slotAddProjectClip);
Julius Künzel's avatar
Julius Künzel committed
363
    connect(onlineResources, &ResourceWidget::addLicenseInfo, this, &MainWindow::slotAddTextNote);
364

365
    // Close library and audiospectrum and others on first run
366
    screenGrabDock->close();
367
    libraryDock->close();
368
    subtitlesDock->close();
369
    textEditingDock->close();
370
    spectrumDock->close();
371
    clipDockWidget->close();
372
    m_onlineResourcesDock->close();
373

374
    m_assetPanel = new AssetPanel(this);
375
    m_effectStackDock = addDock(i18n("Effect/Composition Stack"), QStringLiteral("effect_stack"), m_assetPanel);
376
377
    connect(m_assetPanel, &AssetPanel::doSplitEffect, m_projectMonitor, &Monitor::slotSwitchCompare);
    connect(m_assetPanel, &AssetPanel::doSplitBinEffect, m_clipMonitor, &Monitor::slotSwitchCompare);
Vincent Pinon's avatar
Vincent Pinon committed
378
    connect(m_assetPanel, &AssetPanel::switchCurrentComposition, this, [&](int cid, const QString &compositionId) {
379
380
381
        getMainTimeline()->controller()->getModel()->switchComposition(cid, compositionId);
    });

382
    connect(m_timelineTabs, &TimelineTabs::showMixModel, m_assetPanel, &AssetPanel::showMix);
383
    connect(m_timelineTabs, &TimelineTabs::showTransitionModel, m_assetPanel, &AssetPanel::showTransition);
Vincent Pinon's avatar
Vincent Pinon committed
384
    connect(m_timelineTabs, &TimelineTabs::showTransitionModel, this, [&] () {
385
386
        m_effectStackDock->raise();
    });
387
    connect(m_timelineTabs, &TimelineTabs::showItemEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
Vincent Pinon's avatar
Vincent Pinon committed
388
    connect(m_timelineTabs, &TimelineTabs::showItemEffectStack, this, [&] () {
389
390
391
        m_effectStackDock->raise();
    });

392
393
394
395
396
397
398
399
    connect(m_timelineTabs, &TimelineTabs::showSubtitle, this, [&, subtitlesDock] (int id) {
        if (id > -1) {
            subtitlesDock->show();
            subtitlesDock->raise();
        }
        pCore->subtitleWidget()->setActiveSubtitle(id);
    });

400
    connect(m_timelineTabs, &TimelineTabs::updateZoom, this, &MainWindow::updateZoomSlider);
401
    connect(pCore->bin(), &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
402
    connect(pCore->bin(), &Bin::requestShowEffectStack, [&] () {
403
404
        // Don't raise effect stack on clip bin in case it is docked with bin or clip monitor
        // m_effectStackDock->raise();
405
    });
406
    connect(this, &MainWindow::clearAssetPanel, m_assetPanel, &AssetPanel::clearAssetPanel);
407
    connect(this, &MainWindow::assetPanelWarning, m_assetPanel, &AssetPanel::assetPanelWarning);
Vincent Pinon's avatar
Vincent Pinon committed
408
    connect(m_assetPanel, &AssetPanel::seekToPos, this, [this](int pos) {
409
410
        ObjectId oId = m_assetPanel->effectStackOwner();
        switch (oId.first) {
Nicolas Carion's avatar
Nicolas Carion committed
411
412
413
        case ObjectType::TimelineTrack:
        case ObjectType::TimelineClip:
        case ObjectType::TimelineComposition:
414
        case ObjectType::Master:
415
        case ObjectType::TimelineMix:
416
            m_projectMonitor->requestSeek(pos);
Nicolas Carion's avatar
Nicolas Carion committed
417
418
419
420
421
422
423
            break;
        case ObjectType::BinClip:
            m_clipMonitor->requestSeek(pos);
            break;
        default:
            qDebug() << "ERROR unhandled object type";
            break;
424
425
        }
    });
426

427
428
    m_effectList2 = new EffectListWidget(this);
    connect(m_effectList2, &EffectListWidget::activateAsset, pCore->projectManager(), &ProjectManager::activateAsset);
429
    connect(m_assetPanel, &AssetPanel::reloadEffect, m_effectList2, &EffectListWidget::reloadCustomEffect);
430
    m_effectListDock = addDock(i18n("Effects"), QStringLiteral("effect_list"), m_effectList2);
Simon Eugster's avatar
Simon Eugster committed
431

432
    m_transitionList2 = new TransitionListWidget(this);
433
    m_transitionListDock = addDock(i18n("Compositions"), QStringLiteral("transition_list"), m_transitionList2);
434

Simon Eugster's avatar
Simon Eugster committed
435
    // Add monitors here to keep them at the right of the window
436
437
    m_clipMonitorDock = addDock(i18n("Clip Monitor"), QStringLiteral("clip_monitor"), m_clipMonitor);
    m_projectMonitorDock = addDock(i18n("Project Monitor"), QStringLiteral("project_monitor"), m_projectMonitor);
Simon Eugster's avatar
Simon Eugster committed
438

439
    m_undoView = new QUndoView();
440
    m_undoView->setCleanIcon(QIcon::fromTheme(QStringLiteral("edit-clear")));
441
442
    m_undoView->setEmptyLabel(i18n("Clean"));
    m_undoView->setGroup(m_commandStack);
443
    m_undoViewDock = addDock(i18n("Undo History"), QStringLiteral("undo_history"), m_undoView);
444

445
    // Color and icon theme stuff
Laurent Montel's avatar
Laurent Montel committed
446
    connect(m_commandStack, &QUndoGroup::cleanChanged, m_saveAction, &QAction::setDisabled);
447
    addAction(QStringLiteral("styles_menu"), stylesAction);
Simon Eugster's avatar
Simon Eugster committed
448

449
450
451
452
453
    QAction *iconAction = new QAction(i18n("Force Breeze Icon Theme"), this);
    iconAction->setCheckable(true);
    iconAction->setChecked(KdenliveSettings::force_breeze());
    addAction(QStringLiteral("force_icon_theme"), iconAction);
    connect(iconAction, &QAction::triggered, this, &MainWindow::forceIconSet);
454

455
    m_mixerDock = addDock(i18n("Audio Mixer"), QStringLiteral("mixer"), pCore->mixer());
456
    QAction *showMixer = new QAction(QIcon::fromTheme(QStringLiteral("view-media-equalizer")), i18n("Audio Mixer"), this);
457
458
    showMixer->setCheckable(true);
    addAction(QStringLiteral("audiomixer_button"), showMixer);
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
459
    connect(m_mixerDock, &QDockWidget::visibilityChanged, this, [&, showMixer](bool visible) {
460
461
462
        pCore->mixer()->connectMixer(visible);
        showMixer->setChecked(visible);
    });
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
463
    connect(showMixer, &QAction::triggered, this, [&]() {
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
464
465
        if (m_mixerDock->isVisible() && !m_mixerDock->visibleRegion().isEmpty()) {
            m_mixerDock->close();
466
        } else {
467
468
            m_mixerDock->show();
            m_mixerDock->raise();
469
470
471
        }
    });

Simon Eugster's avatar
Simon Eugster committed
472
473
474
    // Close non-general docks for the initial layout
    // only show important ones
    m_undoViewDock->close();
475
    m_mixerDock->close();
Simon Eugster's avatar
Simon Eugster committed
476

477
    /// Tabify Widgets
478
    tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
479
    tabifyDockWidget(m_transitionListDock, m_effectListDock);
480
    tabifyDockWidget(m_effectStackDock, pCore->bin()->clipPropertiesDock());
481
    bool firstRun = readOptions();
Simon Eugster's avatar
Simon Eugster committed
482

483
    // Build effects menu
484
    m_effectsMenu = new QMenu(i18n("Add Effect"), this);
485
    m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
486
    m_effectList2->reloadEffectMenu(m_effectsMenu, m_effectActions);
487

488
489
490
    m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
    m_transitionActions = new KActionCategory(i18n("Transitions"), actionCollection());

Nicolas Carion's avatar
Nicolas Carion committed
491
    auto *scmanager = new ScopeManager(this);
492

493
    auto *titleBars = new HideTitleBars(this);
494
    connect(layoutManager, &LayoutManagement::updateTitleBars, titleBars, &HideTitleBars::updateTitleBars);
495
    new DockAreaOrientationManager(this);
496
497
    m_extraFactory = new KXMLGUIClient(this);
    buildDynamicActions();
498

499
    // Create Effect Basket (dropdown list of favorites)
500
501
    m_effectBasket = new EffectBasket(this);
    connect(m_effectBasket, &EffectBasket::activateAsset, pCore->projectManager(), &ProjectManager::activateAsset);
502
    connect(m_effectList2, &EffectListWidget::reloadFavorites, m_effectBasket, &EffectBasket::slotReloadBasket);
Nicolas Carion's avatar
Nicolas Carion committed
503
    auto *widgetlist = new QWidgetAction(this);
504
    widgetlist->setDefaultWidget(m_effectBasket);
Nicolas Carion's avatar
Nicolas Carion committed
505
    // widgetlist->setText(i18n("Favorite Effects"));
506
    widgetlist->setToolTip(i18n("Favorite Effects"));
507
    widgetlist->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
Nicolas Carion's avatar
Nicolas Carion committed
508
    auto *menu = new QMenu(this);
509
510
    menu->addAction(widgetlist);

Nicolas Carion's avatar
Nicolas Carion committed
511
    auto *basketButton = new QToolButton(this);
512
    basketButton->setMenu(menu);
513
    basketButton->setToolButtonStyle(toolBar()->toolButtonStyle());
514
515
    basketButton->setDefaultAction(widgetlist);
    basketButton->setPopupMode(QToolButton::InstantPopup);
Nicolas Carion's avatar
Nicolas Carion committed
516
    // basketButton->setText(i18n("Favorite Effects"));
517
    basketButton->setToolTip(i18n("Favorite Effects"));
518
    basketButton->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
519

Nicolas Carion's avatar
Nicolas Carion committed
520
    auto *toolButtonAction = new QWidgetAction(this);
521
    toolButtonAction->setText(i18n("Favorite Effects"));
522
    toolButtonAction->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
523
    toolButtonAction->setDefaultWidget(basketButton);
524
    addAction(QStringLiteral("favorite_effects"), toolButtonAction);
Laurent Montel's avatar
Laurent Montel committed
525
    connect(toolButtonAction, &QAction::triggered, basketButton, &QToolButton::showMenu);
526
    connect(m_effectBasket, &EffectBasket::activateAsset, menu, &QMenu::close);
527

528
529
    // Render button
    ProgressButton *timelineRender = new ProgressButton(i18n("Render"), 100, this);
Nicolas Carion's avatar
Nicolas Carion committed
530
    auto *tlrMenu = new QMenu(this);
531
532
    timelineRender->setMenu(tlrMenu);
    connect(this, &MainWindow::setRenderProgress, timelineRender, &ProgressButton::setProgress);
Nicolas Carion's avatar
Nicolas Carion committed
533
    auto *renderButtonAction = new QWidgetAction(this);
534
    renderButtonAction->setText(i18n("Render Button"));
535
    renderButtonAction->setIcon(QIcon::fromTheme(QStringLiteral("media-record")));
536
537
538
    renderButtonAction->setDefaultWidget(timelineRender);
    addAction(QStringLiteral("project_render_button"), renderButtonAction);

539
    // Timeline preview button
540
    ProgressButton *timelinePreview = new ProgressButton(i18n("Rendering preview"), 1000, this);
Nicolas Carion's avatar
Nicolas Carion committed
541
    auto *tlMenu = new QMenu(this);
542
    timelinePreview->setMenu(tlMenu);
543
    connect(this, &MainWindow::setPreviewProgress, timelinePreview, &ProgressButton::setProgress);
Nicolas Carion's avatar
Nicolas Carion committed
544
    auto *previewButtonAction = new QWidgetAction(this);
545
    previewButtonAction->setText(i18n("Timeline Preview"));
546
    previewButtonAction->setIcon(QIcon::fromTheme(QStringLiteral("preview-render-on")));
547
    previewButtonAction->setDefaultWidget(timelinePreview);
548
    addAction(QStringLiteral("timeline_preview_button"), previewButtonAction);
549

550
    setupGUI(KXmlGuiWindow::ToolBar | KXmlGuiWindow::StatusBar | KXmlGuiWindow::Save | KXmlGuiWindow::Create);
551
    LocaleHandling::resetLocale();
552
    if (firstRun) {
553
        if (QScreen *current = QApplication::primaryScreen()) {
554
555
            int screenHeight = current->availableSize().height();
            if (screenHeight < 1000) {
556
                resize(current->availableSize());
557
            } else if (screenHeight < 2000) {
558
                resize(current->availableSize() / 1.2);
559
            } else {
560
                resize(current->availableSize() / 1.6);
561
562
563
            }
        }
    }
564

565
566
    m_timelineToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
    m_timelineToolBar->setProperty("otherToolbar", true);
567
568
    timelinePreview->setToolButtonStyle(m_timelineToolBar->toolButtonStyle());
    connect(m_timelineToolBar, &QToolBar::toolButtonStyleChanged, timelinePreview, &ProgressButton::setToolButtonStyle);
569

570
    timelineRender->setToolButtonStyle(toolBar()->toolButtonStyle());
571
572
    /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
    guiFactory()->addClient(sp);*/
573

574
    loadGenerators();
575
    loadDockActions();
576
    loadClipActions();
577

578
    // Timeline clip menu
579
    auto *timelineClipMenu = new QMenu(this);
580
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
581
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("paste_effects")));
582
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("delete_effects")));
583
584
585
586
587
588
589
590
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("group_clip")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("ungroup_clip")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_duration")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("clip_split")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("clip_switch")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("delete_timeline_clip")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("extract_clip")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("save_to_bin")));
591
592

    QMenu *markerMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this));
593
    timelineClipMenu->addMenu(markerMenu);
594

595
596
597
598
599
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("set_audio_align_ref")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("align_audio")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_speed")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("clip_in_project_tree")));
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("cut_timeline_clip")));
600

601
    // Timeline composition menu
602
    auto *compositionMenu = new QMenu(this);
603
604
605
606
    compositionMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_duration")));
    compositionMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
    compositionMenu->addAction(actionCollection()->action(QStringLiteral("delete_timeline_clip")));

607
    // Timeline main menu
608
    auto *timelineMenu = new QMenu(this);
609
610
611
612
613
614
615
616
617
    timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_paste")));
    timelineMenu->addAction(actionCollection()->action(QStringLiteral("insert_space")));
    timelineMenu->addAction(actionCollection()->action(QStringLiteral("delete_space")));
    timelineMenu->addAction(actionCollection()->action(QStringLiteral("delete_space_all_tracks")));
    timelineMenu->addAction(actionCollection()->action(QStringLiteral("add_guide")));
    timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_guide")));
    QMenu *guideMenu = new QMenu(i18n("Go to Guide..."), this);
    timelineMenu->addMenu(guideMenu);

618
    // Timeline ruler menu
619
    auto *timelineRulerMenu = new QMenu(this);
620
621
622
623
    timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_guide")));
    timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("edit_guide")));
    timelineRulerMenu->addMenu(guideMenu);
    timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_project_note")));
624
    timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_subtitle")));
625

Sashmita Raghav's avatar
Sashmita Raghav committed
626
    //Timeline subtitle menu
627
    auto *timelineSubtitleMenu = new QMenu(this);
628
    timelineSubtitleMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
Sashmita Raghav's avatar
Sashmita Raghav committed
629
630
    timelineSubtitleMenu->addAction(actionCollection()->action(QStringLiteral("delete_subtitle_clip")));

631
    // Timeline headers menu
632
    auto *timelineHeadersMenu = new QMenu(this);
633
634
    timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("insert_track")));
    timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("delete_track")));
635
    timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("show_track_record")));
636

637
638
639
    QAction *separate_channels = new QAction(QIcon(), i18n("Separate Channels"), this);
    separate_channels->setCheckable(true);
    separate_channels->setChecked(KdenliveSettings::displayallchannels());
640
    separate_channels->setData("separate_channels");
641
642
    connect(separate_channels, &QAction::triggered, this, &MainWindow::slotSeparateAudioChannel);
    timelineHeadersMenu->addAction(separate_channels);
643
644
645
646
647
648
649
    
    QAction *normalize_channels = new QAction(QIcon(), i18n("Normalize Audio Thumbnails"), this);
    normalize_channels->setCheckable(true);
    normalize_channels->setChecked(KdenliveSettings::normalizechannels());
    normalize_channels->setData("normalize_channels");
    connect(normalize_channels, &QAction::triggered, this, &MainWindow::slotNormalizeAudioChannel);
    timelineHeadersMenu->addAction(normalize_channels);
650

651
    QMenu *thumbsMenu = new QMenu(i18n("Thumbnails"), this);
652
    auto *thumbGroup = new QActionGroup(this);
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
    QAction *inFrame = new QAction(i18n("In Frame"), thumbGroup);
    inFrame->setData(QStringLiteral("2"));
    inFrame->setCheckable(true);
    thumbsMenu->addAction(inFrame);
    QAction *inOutFrame = new QAction(i18n("In/Out Frames"), thumbGroup);
    inOutFrame->setData(QStringLiteral("0"));
    inOutFrame->setCheckable(true);
    thumbsMenu->addAction(inOutFrame);
    QAction *allFrame = new QAction(i18n("All Frames"), thumbGroup);
    allFrame->setData(QStringLiteral("1"));
    allFrame->setCheckable(true);
    thumbsMenu->addAction(allFrame);
    QAction *noFrame = new QAction(i18n("No Thumbnails"), thumbGroup);
    noFrame->setData(QStringLiteral("3"));
    noFrame->setCheckable(true);
    thumbsMenu->addAction(noFrame);
669

670
671
672
673
674
675
676
677
678
679
680
    QMenu *openGLMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("qt_opengl"), this));
#if defined(Q_OS_WIN)
    connect(openGLMenu, &QMenu::triggered, [&](QAction *ac) {
        KdenliveSettings::setOpengl_backend(ac->data().toInt());
        if (KMessageBox::questionYesNo(this, i18n("Kdenlive needs to be restarted to change this setting. Do you want to proceed?")) != KMessageBox::Yes) {
            return;
        }
        slotRestart(false);
    });
#else
    if (openGLMenu) {
681
        openGLMenu->menuAction()->setVisible(false);;
682
683
    }
#endif
684
    // Connect monitor overlay info menu.
Laurent Montel's avatar
Laurent Montel committed
685
    QMenu *monitorOverlay = static_cast<QMenu *>(factory()->container(QStringLiteral("monitor_config_overlay"), this));
Laurent Montel's avatar
Laurent Montel committed
686
    connect(monitorOverlay, &QMenu::triggered, this, &MainWindow::slotSwitchMonitorOverlay);
687

Nicolas Carion's avatar
Nicolas Carion committed
688
689
690
691
    m_projectMonitor->setupMenu(static_cast<QMenu *>(factory()->container(QStringLiteral("monitor_go"), this)), monitorOverlay, m_playZone, m_loopZone, nullptr,
                                m_loopClip);
    m_clipMonitor->setupMenu(static_cast<QMenu *>(factory()->container(QStringLiteral("monitor_go"), this)), monitorOverlay, m_playZone, m_loopZone,
                             static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this)));
692

Laurent Montel's avatar
Laurent Montel committed
693
    QMenu *clipInTimeline = static_cast<QMenu *>(factory()->container(QStringLiteral("clip_in_timeline"), this));
694
    clipInTimeline->setIcon(QIcon::fromTheme(QStringLiteral("go-jump")));
695
    pCore->bin()->setupGeneratorMenu();
Marco Gittler's avatar
Marco Gittler committed
696

Laurent Montel's avatar
Laurent Montel committed
697
    connect(pCore->monitorManager(), &MonitorManager::updateOverlayInfos, this, &MainWindow::slotUpdateMonitorOverlays);
698

699
    // Setup and fill effects and transitions menus.
Laurent Montel's avatar
Laurent Montel committed
700
    QMenu *m = static_cast<QMenu *>(factory()->container(QStringLiteral("video_effects_menu"), this));
701
702
    connect(m, &QMenu::triggered, this, &MainWindow::slotAddEffect);
    connect(m_effectsMenu, &QMenu::triggered, this, &MainWindow::slotAddEffect);
Laurent Montel's avatar
Laurent Montel committed
703
    connect(m_transitionsMenu, &QMenu::triggered, this, &MainWindow::slotAddTransition);
704

705
706
    m_timelineContextMenu = new QMenu(this);

707
708
    m_timelineContextMenu->addAction(actionCollection()->action(QStringLiteral("insert_space")));
    m_timelineContextMenu->addAction(actionCollection()->action(QStringLiteral("delete_space")));
709
    m_timelineContextMenu->addAction(actionCollection()->action(QStringLiteral("delete_space_all_tracks")));
710
711
    m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));

712
    // QMenu *markersMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this));
713
714
715
716
717

    /*m_timelineClipActions->addMenu(markersMenu);
    m_timelineClipActions->addSeparator();
    m_timelineClipActions->addMenu(m_transitionsMenu);
    m_timelineClipActions->addMenu(m_effectsMenu);*/
Marco Gittler's avatar
Marco Gittler committed
718

719
    slotConnectMonitors();
720

721
    m_timelineToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
722
    // TODO: let user select timeline toolbar toolbutton style
Nicolas Carion's avatar
Nicolas Carion committed
723
    // connect(toolBar(), &QToolBar::iconSizeChanged, m_timelineToolBar, &QToolBar::setToolButtonStyle);
724
725
    m_timelineToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_timelineToolBar, &QWidget::customContextMenuRequested, this, &MainWindow::showTimelineToolbarMenu);
726
727

    QAction *prevRender = actionCollection()->action(QStringLiteral("prerender_timeline_zone"));
728
729
    QAction *stopPrevRender = actionCollection()->action(QStringLiteral("stop_prerender_timeline"));
    tlMenu->addAction(stopPrevRender);
730
731
    tlMenu->addAction(actionCollection()->action(QStringLiteral("set_render_timeline_zone")));
    tlMenu->addAction(actionCollection()->action(QStringLiteral("unset_render_timeline_zone")));
732
    tlMenu->addAction(actionCollection()->action(QStringLiteral("clear_render_timeline_zone")));
733
734

    // Automatic timeline preview action
735
    QAction *autoRender = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Automatic Preview"), this);
736
737
738
739
    autoRender->setCheckable(true);
    autoRender->setChecked(KdenliveSettings::autopreview());
    connect(autoRender, &QAction::triggered, this, &MainWindow::slotToggleAutoPreview);
    tlMenu->addAction(autoRender);
740
    tlMenu->addSeparator();
741
    tlMenu->addAction(actionCollection()->action(QStringLiteral("disable_preview")));
742
    tlMenu->addAction(actionCollection()->action(QStringLiteral("manage_cache")));
743
    timelinePreview->defineDefaultAction(prevRender, stopPrevRender);
744
    timelinePreview->setAutoRaise(true);
745

746
747
    QAction *showRender = actionCollection()->action(QStringLiteral("project_render"));
    tlrMenu->addAction(showRender);