mainwindow.cpp 174 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"
Nicolas Carion's avatar
Nicolas Carion committed
24
#include "bin/projectclip.h"
25
26
#include "bin/projectfolder.h"
#include "bin/projectitemmodel.h"
Nicolas Carion's avatar
Nicolas Carion committed
27
#include "core.h"
28
#include "dialogs/clipcreationdialog.h"
Nicolas Carion's avatar
Nicolas Carion committed
29
30
31
#include "dialogs/kdenlivesettingsdialog.h"
#include "dialogs/renderwidget.h"
#include "dialogs/wizard.h"
32
#include "doc/docundostack.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
33
#include "doc/kdenlivedoc.h"
34
#include "effects/effectlist/view/effectlistwidget.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
35
36
#include "effectslist/effectbasket.h"
#include "hidetitlebars.h"
37
38
#include "jobs/jobmanager.h"
#include "jobs/scenesplitjob.hpp"
39
#include "jobs/speedjob.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
40
#include "jobs/stabilizejob.hpp"
41
#include "jobs/transcodeclipjob.h"
Nicolas Carion's avatar
Nicolas Carion committed
42
43
44
#include "kdenlivesettings.h"
#include "layoutmanagement.h"
#include "library/librarywidget.h"
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
45
#include "audiomixer/mixermanager.hpp"
Nicolas Carion's avatar
Nicolas Carion committed
46
47
48
49
50
51
#include "mainwindowadaptor.h"
#include "mltconnection.h"
#include "mltcontroller/clipcontroller.h"
#include "monitor/monitor.h"
#include "monitor/monitormanager.h"
#include "monitor/scopes/audiographspectrum.h"
Nicolas Carion's avatar
linting    
Nicolas Carion committed
52
#include "profiles/profilemodel.hpp"
Vincent Pinon's avatar
Vincent Pinon committed
53
#include "project/cliptranscode.h"
Vincent Pinon's avatar
Vincent Pinon committed
54
#include "project/dialogs/archivewidget.h"
Nicolas Carion's avatar
Nicolas Carion committed
55
56
#include "project/dialogs/projectsettings.h"
#include "project/projectcommands.h"
Till Theato's avatar
Till Theato committed
57
#include "project/projectmanager.h"
Nicolas Carion's avatar
Nicolas Carion committed
58
#include "scopes/scopemanager.h"
Nicolas Carion's avatar
linting    
Nicolas Carion committed
59
#include "timeline2/view/timelinecontroller.h"
60
#include "timeline2/view/timelinetabs.hpp"
61
#include "timeline2/view/timelinewidget.h"
Nicolas Carion's avatar
Nicolas Carion committed
62
63
64
65
66
#include "titler/titlewidget.h"
#include "transitions/transitionlist/view/transitionlistwidget.hpp"
#include "transitions/transitionsrepository.hpp"
#include "utils/resourcewidget.h"
#include "utils/thememanager.h"
Vincent Pinon's avatar
Vincent Pinon committed
67
#include "utils/otioconvertions.h"
68

69
#include "profiles/profilerepository.hpp"
70
71
#include "widgets/progressbutton.h"
#include <config-kdenlive.h>
72

73
#include "project/dialogs/temporarydata.h"
74

75
76
77
#ifdef USE_JOGSHUTTLE
#include "jogshuttle/jogmanager.h"
#endif
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
78

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

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

115
static const char version[] = KDENLIVE_VERSION;
Nicolas Carion's avatar
Nicolas Carion committed
116
namespace Mlt {
117
class Producer;
Laurent Montel's avatar
Laurent Montel committed
118
}
119

Laurent Montel's avatar
Laurent Montel committed
120
121
QMap<QString, QImage> MainWindow::m_lumacache;
QMap<QString, QStringList> MainWindow::m_lumaFiles;
122

123
/*static bool sortByNames(const QPair<QString, QAction *> &a, const QPair<QString, QAction*> &b)
124
125
{
    return a.first < b.first;
126
}*/
127

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

Nicolas Carion's avatar
Nicolas Carion committed
137
MainWindow::MainWindow(QWidget *parent)
138
    : KXmlGuiWindow(parent)
Nicolas Carion's avatar
Nicolas Carion committed
139

140
{
141
142
}

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

151
152
153
154
    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
155

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

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

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

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

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

    new RenderingAdaptor(this);
202
    QString defaultProfile = KdenliveSettings::default_profile();
203
    pCore->setCurrentProfile(defaultProfile.isEmpty() ? ProjectManager::getDefaultProjectFormat() : defaultProfile);
204
    m_commandStack = new QUndoGroup();
205
206

    // If using a custom profile, make sure the file exists or fallback to default
207
208
    QString currentProfilePath = pCore->getCurrentProfile()->path();
    if (currentProfilePath.startsWith(QLatin1Char('/')) && !QFile::exists(currentProfilePath)) {
209
        KMessageBox::sorry(this, i18n("Cannot find your default profile, switching to ATSC 1080p 25"));
210
        pCore->setCurrentProfile(QStringLiteral("atsc_1080p_25"));
Laurent Montel's avatar
Laurent Montel committed
211
        KdenliveSettings::setDefault_profile(QStringLiteral("atsc_1080p_25"));
212
    }
213

214
    m_gpuAllowed = EffectsRepository::get()->hasInternalEffect(QStringLiteral("glsl.manager"));
215

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

219
    /// Add Widgets
220
    setDockOptions(dockOptions() | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
221
    setDockOptions(dockOptions() | QMainWindow::GroupedDragging);
Nicolas Carion's avatar
Nicolas Carion committed
222
    setTabPosition(Qt::AllDockWidgetAreas, (QTabWidget::TabPosition)KdenliveSettings::tabposition());
223
    m_timelineToolBar = toolBar(QStringLiteral("timelineToolBar"));
224
    m_timelineToolBarContainer = new TimelineContainer(this);
Nicolas Carion's avatar
Nicolas Carion committed
225
    auto *ctnLay = new QVBoxLayout;
226
227
    ctnLay->setSpacing(0);
    ctnLay->setContentsMargins(0, 0, 0, 0);
228
229
    m_timelineToolBarContainer->setLayout(ctnLay);
    ctnLay->addWidget(m_timelineToolBar);
230
231
232
233
    KSharedConfigPtr config = KSharedConfig::openConfig();
    KConfigGroup mainConfig(config, QStringLiteral("MainWindow"));
    KConfigGroup tbGroup(&mainConfig, QStringLiteral("Toolbar timelineToolBar"));
    m_timelineToolBar->applySettings(tbGroup);
234
235
236
237
238
    QFrame *fr = new QFrame(this);
    fr->setFrameShape(QFrame::HLine);
    fr->setMaximumHeight(1);
    fr->setLineWidth(1);
    ctnLay->addWidget(fr);
239
    setupActions();
240

Laurent Montel's avatar
Laurent Montel committed
241
    QDockWidget *libraryDock = addDock(i18n("Library"), QStringLiteral("library"), pCore->library());
Simon Eugster's avatar
Simon Eugster committed
242

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
243
    m_clipMonitor = new Monitor(Kdenlive::ClipMonitor, pCore->monitorManager(), this);
244
    pCore->bin()->setMonitor(m_clipMonitor);
245
246
    connect(m_clipMonitor, &Monitor::addMarker, this, &MainWindow::slotAddMarkerGuideQuickly);
    connect(m_clipMonitor, &Monitor::deleteMarker, this, &MainWindow::slotDeleteClipMarker);
247
248
    connect(m_clipMonitor, &Monitor::seekToPreviousSnap, this, &MainWindow::slotSnapRewind);
    connect(m_clipMonitor, &Monitor::seekToNextSnap, this, &MainWindow::slotSnapForward);
249

250
    connect(pCore->bin(), &Bin::findInTimeline, this, &MainWindow::slotClipInTimeline, Qt::DirectConnection);
251
252
    connect(pCore->bin(), &Bin::setupTargets, this, [&] (bool hasVideo, QList <int> audioStreams) {
            getCurrentTimeline()->controller()->setTargetTracks(hasVideo, audioStreams);
253
254
        }
    );
255

Nicolas Carion's avatar
Nicolas Carion committed
256
    // TODO deprecated, replace with Bin methods if necessary
257
    /*connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
258
    connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
Laurent Montel's avatar
Laurent Montel committed
259
    connect(m_projectList, SIGNAL(updateProfile(QString)), this, SLOT(slotUpdateProjectProfile(QString)));
260
    connect(m_projectList, SIGNAL(refreshClip(QString,bool)), pCore->monitorManager(), SLOT(slotRefreshCurrentMonitor(QString)));
261
    connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));*/
262

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

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
265
    m_projectMonitor = new Monitor(Kdenlive::ProjectMonitor, pCore->monitorManager(), this);
Laurent Montel's avatar
Laurent Montel committed
266
    connect(m_projectMonitor, &Monitor::passKeyPress, this, &MainWindow::triggerKey);
267
    connect(m_projectMonitor, &Monitor::addMarker, this, &MainWindow::slotAddMarkerGuideQuickly);
268
    connect(m_projectMonitor, &Monitor::deleteMarker, this, &MainWindow::slotDeleteGuide);
269
270
    connect(m_projectMonitor, &Monitor::seekToPreviousSnap, this, &MainWindow::slotSnapRewind);
    connect(m_projectMonitor, &Monitor::seekToNextSnap, this, &MainWindow::slotSnapForward);
271
    connect(m_loopClip, &QAction::triggered, m_projectMonitor, &Monitor::slotLoopClip);
272

273
    pCore->monitorManager()->initMonitors(m_clipMonitor, m_projectMonitor);
274
    connect(m_clipMonitor, &Monitor::addMasterEffect, pCore->bin(), &Bin::slotAddEffect);
275

276
277
    m_timelineTabs = new TimelineTabs(this);
    ctnLay->addWidget(m_timelineTabs);
278
    setCentralWidget(m_timelineToolBarContainer);
279

280
281
282
283
284
285
286
    // Screen grab widget
    QWidget *grabWidget = new QWidget(this);
    QVBoxLayout *grabLayout = new QVBoxLayout;
    grabWidget->setLayout(grabLayout);
    QToolBar *recToolbar = new QToolBar(grabWidget);
    grabLayout->addWidget(recToolbar);
    grabLayout->addStretch(10);
287
    // Check number of monitors for FFmpeg screen capture
Vincent Pinon's avatar
Vincent Pinon committed
288
    int screens = QApplication::screens().count();
289
290
291
292
293
    if (screens > 1) {
        QComboBox *screenCombo = new QComboBox(recToolbar);
        for (int ix = 0; ix < screens; ix++) {
            screenCombo->addItem(i18n("Monitor %1", ix));
        }
Laurent Montel's avatar
Laurent Montel committed
294
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
295
        connect(screenCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), m_clipMonitor, &Monitor::slotSetScreen);
Laurent Montel's avatar
Laurent Montel committed
296
297
298
#else
        connect(screenCombo, static_cast<void (QComboBox::*)(int, const QString &)>(&QComboBox::currentIndexChanged) , m_clipMonitor, &Monitor::slotSetScreen);
#endif
299
300
301
302
        recToolbar->addWidget(screenCombo);
        // Update screen grab monitor choice in case we changed from fullscreen
        screenCombo->setEnabled(KdenliveSettings::grab_capture_type() == 0);
    }
303
304
305
306
307
308
309
310
311
    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, [&]() {
        pCore->showConfigDialog(4, 0);
    });
    QDockWidget *screenGrabDock = addDock(i18n("Screen Grab"), QStringLiteral("screengrab"), grabWidget);
312

313
314
    // Audio spectrum scope
    m_audioSpectrum = new AudioGraphSpectrum(pCore->monitorManager());
Laurent Montel's avatar
Laurent Montel committed
315
    QDockWidget *spectrumDock = addDock(i18n("Audio Spectrum"), QStringLiteral("audiospectrum"), m_audioSpectrum);
316
    // Close library and audiospectrum on first run
317
    screenGrabDock->close();
318
319
320
    libraryDock->close();
    spectrumDock->close();

321
    m_projectBinDock = addDock(i18n("Project Bin"), QStringLiteral("project_bin"), pCore->bin());
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
322

323
    m_assetPanel = new AssetPanel(this);
324
    m_effectStackDock = addDock(i18n("Effect/Composition Stack"), QStringLiteral("effect_stack"), m_assetPanel);
325
326
    connect(m_assetPanel, &AssetPanel::doSplitEffect, m_projectMonitor, &Monitor::slotSwitchCompare);
    connect(m_assetPanel, &AssetPanel::doSplitBinEffect, m_clipMonitor, &Monitor::slotSwitchCompare);
327
328
329
330
    connect(m_assetPanel, &AssetPanel::switchCurrentComposition, [&](int cid, const QString &compositionId) {
        getMainTimeline()->controller()->getModel()->switchComposition(cid, compositionId);
    });

331
    connect(m_timelineTabs, &TimelineTabs::showTransitionModel, m_assetPanel, &AssetPanel::showTransition);
332
333
334
    connect(m_timelineTabs, &TimelineTabs::showTransitionModel, [&] () {
        m_effectStackDock->raise();
    });
335
    connect(m_timelineTabs, &TimelineTabs::showItemEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
336
337
338
339
    connect(m_timelineTabs, &TimelineTabs::showItemEffectStack, [&] () {
        m_effectStackDock->raise();
    });

340
    connect(m_timelineTabs, &TimelineTabs::updateZoom, this, &MainWindow::updateZoomSlider);
341
    connect(pCore->bin(), &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
342
    connect(pCore->bin(), &Bin::requestShowEffectStack, [&] () {
343
344
        // Don't raise effect stack on clip bin in case it is docked with bin or clip monitor
        // m_effectStackDock->raise();
345
    });
346
    connect(this, &MainWindow::clearAssetPanel, m_assetPanel, &AssetPanel::clearAssetPanel);
347
    connect(this, &MainWindow::assetPanelWarning, m_assetPanel, &AssetPanel::assetPanelWarning);
348
349
350
    connect(m_assetPanel, &AssetPanel::seekToPos, [this](int pos) {
        ObjectId oId = m_assetPanel->effectStackOwner();
        switch (oId.first) {
Nicolas Carion's avatar
Nicolas Carion committed
351
352
353
        case ObjectType::TimelineTrack:
        case ObjectType::TimelineClip:
        case ObjectType::TimelineComposition:
354
        case ObjectType::Master:
355
            m_projectMonitor->requestSeek(pos);
Nicolas Carion's avatar
Nicolas Carion committed
356
357
358
359
360
361
362
            break;
        case ObjectType::BinClip:
            m_clipMonitor->requestSeek(pos);
            break;
        default:
            qDebug() << "ERROR unhandled object type";
            break;
363
364
        }
    });
365

366
367
    m_effectList2 = new EffectListWidget(this);
    connect(m_effectList2, &EffectListWidget::activateAsset, pCore->projectManager(), &ProjectManager::activateAsset);
368
    connect(m_assetPanel, &AssetPanel::reloadEffect, m_effectList2, &EffectListWidget::reloadCustomEffect);
369
    m_effectListDock = addDock(i18n("Effects"), QStringLiteral("effect_list"), m_effectList2);
Simon Eugster's avatar
Simon Eugster committed
370

371
    m_transitionList2 = new TransitionListWidget(this);
372
    m_transitionListDock = addDock(i18n("Compositions"), QStringLiteral("transition_list"), m_transitionList2);
373

Simon Eugster's avatar
Simon Eugster committed
374
    // Add monitors here to keep them at the right of the window
375
376
    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
377

378
    m_undoView = new QUndoView();
379
    m_undoView->setCleanIcon(QIcon::fromTheme(QStringLiteral("edit-clear")));
380
381
    m_undoView->setEmptyLabel(i18n("Clean"));
    m_undoView->setGroup(m_commandStack);
382
    m_undoViewDock = addDock(i18n("Undo History"), QStringLiteral("undo_history"), m_undoView);
383

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

388
389
390
391
392
    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);
393

394
    QDockWidget *mixerDock = addDock(i18n("Audio Mixer"), QStringLiteral("mixer"), pCore->mixer());
395
    QAction *showMixer = new QAction(QIcon::fromTheme(QStringLiteral("view-media-equalizer")), i18n("Audio Mixer"), this);
396
397
398
399
400
401
402
    showMixer->setCheckable(true);
    addAction(QStringLiteral("audiomixer_button"), showMixer);
    connect(mixerDock, &QDockWidget::visibilityChanged, [&, showMixer](bool visible) {
        pCore->mixer()->connectMixer(visible);
        showMixer->setChecked(visible);
    });
    connect(showMixer, &QAction::triggered, [&, mixerDock]() {
403
        if (mixerDock->isVisible() && !mixerDock->visibleRegion().isEmpty()) {
404
405
406
            mixerDock->close();
        } else {
            mixerDock->show();
407
            mixerDock->raise();
408
409
410
        }
    });

Simon Eugster's avatar
Simon Eugster committed
411
412
413
    // Close non-general docks for the initial layout
    // only show important ones
    m_undoViewDock->close();
414
    mixerDock->close();
Simon Eugster's avatar
Simon Eugster committed
415

416
    /// Tabify Widgets
417
    tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
418
    tabifyDockWidget(m_transitionListDock, m_effectListDock);
419
    tabifyDockWidget(m_effectStackDock, pCore->bin()->clipPropertiesDock());
420
    bool firstRun = readOptions();
Simon Eugster's avatar
Simon Eugster committed
421

422
    // Build effects menu
423
    m_effectsMenu = new QMenu(i18n("Add Effect"), this);
424
    m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
425
    m_effectList2->reloadEffectMenu(m_effectsMenu, m_effectActions);
426

427
428
429
    m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
    m_transitionActions = new KActionCategory(i18n("Transitions"), actionCollection());

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

Till Theato's avatar
Till Theato committed
432
    new LayoutManagement(this);
433
    new HideTitleBars(this);
434
435
    m_extraFactory = new KXMLGUIClient(this);
    buildDynamicActions();
Vincent Pinon's avatar
Vincent Pinon committed
436
    m_otioConvertions.getOtioConverters();
437

438
    // Create Effect Basket (dropdown list of favorites)
439
440
    m_effectBasket = new EffectBasket(this);
    connect(m_effectBasket, &EffectBasket::activateAsset, pCore->projectManager(), &ProjectManager::activateAsset);
441
    connect(m_effectList2, &EffectListWidget::reloadFavorites, m_effectBasket, &EffectBasket::slotReloadBasket);
Nicolas Carion's avatar
Nicolas Carion committed
442
    auto *widgetlist = new QWidgetAction(this);
443
    widgetlist->setDefaultWidget(m_effectBasket);
Nicolas Carion's avatar
Nicolas Carion committed
444
    // widgetlist->setText(i18n("Favorite Effects"));
445
    widgetlist->setToolTip(i18n("Favorite Effects"));
446
    widgetlist->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
Nicolas Carion's avatar
Nicolas Carion committed
447
    auto *menu = new QMenu(this);
448
449
    menu->addAction(widgetlist);

Nicolas Carion's avatar
Nicolas Carion committed
450
    auto *basketButton = new QToolButton(this);
451
    basketButton->setMenu(menu);
452
    basketButton->setToolButtonStyle(toolBar()->toolButtonStyle());
453
454
    basketButton->setDefaultAction(widgetlist);
    basketButton->setPopupMode(QToolButton::InstantPopup);
Nicolas Carion's avatar
Nicolas Carion committed
455
    // basketButton->setText(i18n("Favorite Effects"));
456
    basketButton->setToolTip(i18n("Favorite Effects"));
457
    basketButton->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
458

Nicolas Carion's avatar
Nicolas Carion committed
459
    auto *toolButtonAction = new QWidgetAction(this);
460
    toolButtonAction->setText(i18n("Favorite Effects"));
461
    toolButtonAction->setIcon(QIcon::fromTheme(QStringLiteral("favorite")));
462
    toolButtonAction->setDefaultWidget(basketButton);
463
    addAction(QStringLiteral("favorite_effects"), toolButtonAction);
Laurent Montel's avatar
Laurent Montel committed
464
    connect(toolButtonAction, &QAction::triggered, basketButton, &QToolButton::showMenu);
465
    connect(m_effectBasket, &EffectBasket::activateAsset, menu, &QMenu::close);
466

467
468
    // Render button
    ProgressButton *timelineRender = new ProgressButton(i18n("Render"), 100, this);
Nicolas Carion's avatar
Nicolas Carion committed
469
    auto *tlrMenu = new QMenu(this);
470
471
    timelineRender->setMenu(tlrMenu);
    connect(this, &MainWindow::setRenderProgress, timelineRender, &ProgressButton::setProgress);
Nicolas Carion's avatar
Nicolas Carion committed
472
    auto *renderButtonAction = new QWidgetAction(this);
473
    renderButtonAction->setText(i18n("Render Button"));
474
    renderButtonAction->setIcon(QIcon::fromTheme(QStringLiteral("media-record")));
475
476
477
    renderButtonAction->setDefaultWidget(timelineRender);
    addAction(QStringLiteral("project_render_button"), renderButtonAction);

478
    // Timeline preview button
479
    ProgressButton *timelinePreview = new ProgressButton(i18n("Rendering preview"), 1000, this);
Nicolas Carion's avatar
Nicolas Carion committed
480
    auto *tlMenu = new QMenu(this);
481
    timelinePreview->setMenu(tlMenu);
482
    connect(this, &MainWindow::setPreviewProgress, timelinePreview, &ProgressButton::setProgress);
Nicolas Carion's avatar
Nicolas Carion committed
483
    auto *previewButtonAction = new QWidgetAction(this);
484
    previewButtonAction->setText(i18n("Timeline Preview"));
485
    previewButtonAction->setIcon(QIcon::fromTheme(QStringLiteral("preview-render-on")));
486
    previewButtonAction->setDefaultWidget(timelinePreview);
487
    addAction(QStringLiteral("timeline_preview_button"), previewButtonAction);
488

489
    setupGUI(KXmlGuiWindow::ToolBar | KXmlGuiWindow::StatusBar | KXmlGuiWindow::Save | KXmlGuiWindow::Create);
490
    if (firstRun) {
491
        if (QScreen *current = QApplication::primaryScreen()) {
492
493
494
495
496
497
498
            if (current->availableSize().height() < 1000) {
                resize(current->availableSize());
            } else {
                resize(current->availableSize() / 1.5);
            }
        }
    }
499
500
501
    updateActionsToolTip();
    m_timelineToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
    m_timelineToolBar->setProperty("otherToolbar", true);
502
503
    timelinePreview->setToolButtonStyle(m_timelineToolBar->toolButtonStyle());
    connect(m_timelineToolBar, &QToolBar::toolButtonStyleChanged, timelinePreview, &ProgressButton::setToolButtonStyle);
504

505
    timelineRender->setToolButtonStyle(toolBar()->toolButtonStyle());
506
507
    /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
    guiFactory()->addClient(sp);*/
508

509
    loadGenerators();
510
    loadDockActions();
511
    loadClipActions();
512

513
    // Timeline clip menu
514
515
    QMenu *timelineClipMenu = new QMenu(this);
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
516
    timelineClipMenu->addAction(actionCollection()->action(QStringLiteral("paste_effects")));
517
518
519
520
521
522
523
524
    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")));
525
526

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

529
530
531
532
533
    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")));
534

535
536
537
538
539
540
    // Timeline composition menu
    QMenu *compositionMenu = new QMenu(this);
    compositionMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_duration")));
    compositionMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
    compositionMenu->addAction(actionCollection()->action(QStringLiteral("delete_timeline_clip")));

541
542
543
544
545
546
547
548
549
550
551
    // Timeline main menu
    QMenu *timelineMenu = new QMenu(this);
    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);

552
553
554
555
556
557
558
559
560
561
562
    // Timeline ruler menu
    QMenu *timelineRulerMenu = new QMenu(this);
    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")));

    // Timeline headers menu
    QMenu *timelineHeadersMenu = new QMenu(this);
    timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("insert_track")));
    timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("delete_track")));
563
    timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("show_track_record")));
564
565
566
567
568
    QAction *separate_channels = new QAction(QIcon(), i18n("Separate Channels"), this);
    separate_channels->setCheckable(true);
    separate_channels->setChecked(KdenliveSettings::displayallchannels());
    connect(separate_channels, &QAction::triggered, this, &MainWindow::slotSeparateAudioChannel);
    timelineHeadersMenu->addAction(separate_channels);
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
    QMenu *thumbsMenu = new QMenu(i18n("Thumbnails"), this);
    QActionGroup *thumbGroup = new QActionGroup(this);
    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);
587

588
589
590
591
592
593
594
595
596
597
598
    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) {
599
        openGLMenu->menuAction()->setVisible(false);;
600
601
    }
#endif
602
    // Connect monitor overlay info menu.
Laurent Montel's avatar
Laurent Montel committed
603
    QMenu *monitorOverlay = static_cast<QMenu *>(factory()->container(QStringLiteral("monitor_config_overlay"), this));
Laurent Montel's avatar
Laurent Montel committed
604
    connect(monitorOverlay, &QMenu::triggered, this, &MainWindow::slotSwitchMonitorOverlay);
605

Nicolas Carion's avatar
Nicolas Carion committed
606
607
608
609
    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)));
610

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

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

617
    // Setup and fill effects and transitions menus.
Laurent Montel's avatar
Laurent Montel committed
618
    QMenu *m = static_cast<QMenu *>(factory()->container(QStringLiteral("video_effects_menu"), this));
619
620
    connect(m, &QMenu::triggered, this, &MainWindow::slotAddEffect);
    connect(m_effectsMenu, &QMenu::triggered, this, &MainWindow::slotAddEffect);
Laurent Montel's avatar
Laurent Montel committed
621
    connect(m_transitionsMenu, &QMenu::triggered, this, &MainWindow::slotAddTransition);
622

623
624
    m_timelineContextMenu = new QMenu(this);

625
626
    m_timelineContextMenu->addAction(actionCollection()->action(QStringLiteral("insert_space")));
    m_timelineContextMenu->addAction(actionCollection()->action(QStringLiteral("delete_space")));
627
    m_timelineContextMenu->addAction(actionCollection()->action(QStringLiteral("delete_space_all_tracks")));
628
629
    m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));

630
    // QMenu *markersMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this));
631
632
633
634
635

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

637
    slotConnectMonitors();
638

639
    m_timelineToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
640
    // TODO: let user select timeline toolbar toolbutton style
Nicolas Carion's avatar
Nicolas Carion committed
641
    // connect(toolBar(), &QToolBar::iconSizeChanged, m_timelineToolBar, &QToolBar::setToolButtonStyle);
642
643
    m_timelineToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_timelineToolBar, &QWidget::customContextMenuRequested, this, &MainWindow::showTimelineToolbarMenu);
644
645

    QAction *prevRender = actionCollection()->action(QStringLiteral("prerender_timeline_zone"));
646
647
    QAction *stopPrevRender = actionCollection()->action(QStringLiteral("stop_prerender_timeline"));
    tlMenu->addAction(stopPrevRender);
648
649
    tlMenu->addAction(actionCollection()->action(QStringLiteral("set_render_timeline_zone")));
    tlMenu->addAction(actionCollection()->action(QStringLiteral("unset_render_timeline_zone")));
650
    tlMenu->addAction(actionCollection()->action(QStringLiteral("clear_render_timeline_zone")));
651
652

    // Automatic timeline preview action
653
    QAction *autoRender = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Automatic Preview"), this);
654
655
656
657
    autoRender->setCheckable(true);
    autoRender->setChecked(KdenliveSettings::autopreview());
    connect(autoRender, &QAction::triggered, this, &MainWindow::slotToggleAutoPreview);
    tlMenu->addAction(autoRender);
658
    tlMenu->addSeparator();
659
    tlMenu->addAction(actionCollection()->action(QStringLiteral("disable_preview")));
660
    tlMenu->addAction(actionCollection()->action(QStringLiteral("manage_cache")));
661
    timelinePreview->defineDefaultAction(prevRender, stopPrevRender);
662
    timelinePreview->setAutoRaise(true);
663

664
665
    QAction *showRender = actionCollection()->action(QStringLiteral("project_render"));
    tlrMenu->addAction(showRender);
666
    tlrMenu->addAction(actionCollection()->action(QStringLiteral("stop_project_render")));
667
    timelineRender->defineDefaultAction(showRender, showRender);
668
669
    timelineRender->setAutoRaise(true);

670
    // Populate encoding profiles
671
    KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::AppDataLocation);
672
    /*KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::AppDataLocation);
673
    if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
674
        KConfigGroup group(&conf, "proxy");
Nicolas Carion's avatar
Nicolas Carion committed
675
        QMap<QString, QString> values = group.entryMap();
676
677
678
        QMapIterator<QString, QString> i(values);
        if (i.hasNext()) {
            i.next();
679
680
681
            QString proxystring = i.value();
            KdenliveSettings::setProxyparams(proxystring.section(QLatin1Char(';'), 0, 0));
            KdenliveSettings::setProxyextension(proxystring.section(QLatin1Char(';'), 1, 1));
682
        }
683
    }*/
684
    if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
685
        KConfigGroup group(&conf, "video4linux");
Nicolas Carion's avatar
Nicolas Carion committed
686
        QMap<QString, QString> values = group.entryMap();
687
688
689
        QMapIterator<QString, QString> i(values);
        if (i.hasNext()) {
            i.next();
690
691
692
            QString v4lstring = i.value();
            KdenliveSettings::setV4l_parameters(v4lstring.section(QLatin1Char(';'), 0, 0));
            KdenliveSettings::setV4l_extension(v4lstring.section(QLatin1Char(';'), 1, 1));
693
694
        }
    }
695
696
    if (KdenliveSettings::grab_parameters().isEmpty() || KdenliveSettings::grab_extension().isEmpty()) {
        KConfigGroup group(&conf, "screengrab");
Nicolas Carion's avatar
Nicolas Carion committed
697
        QMap<QString, QString> values = group.entryMap();
698
699
700
        QMapIterator<QString, QString> i(values);
        if (i.hasNext()) {
            i.next();
701
702
703
            QString grabstring = i.value();
            KdenliveSettings::setGrab_parameters(grabstring.section(QLatin1Char(';'), 0, 0));
            KdenliveSettings::setGrab_extension(grabstring.section(QLatin1Char(';'), 1, 1));
704
705
        }
    }
706
    if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
707
        KConfigGroup group(&conf, "decklink");
Nicolas Carion's avatar
Nicolas Carion committed
708
        QMap<QString, QString> values = group.entryMap();
709
710
711
        QMapIterator<QString, QString> i(values);
        if (i.hasNext()) {
            i.next();
712
713
714
            QString decklinkstring = i.value();
            KdenliveSettings::setDecklink_parameters(decklinkstring.section(QLatin1Char(';'), 0, 0));
            KdenliveSettings::setDecklink_extension(decklinkstring.section(QLatin1Char(';'), 1, 1));
715
716
        }
    }
Vincent Pinon's avatar
Vincent Pinon committed
717
718
719
    if (!QDir(KdenliveSettings::currenttmpfolder()).isReadable())
        KdenliveSettings::setCurrenttmpfolder(QStandardPaths::writableLocation(QStandardPaths::TempLocation));

Laurent Montel's avatar
Laurent Montel committed
720
    QTimer::singleShot(0, this, &MainWindow::GUISetupDone);
721

722
723
724
#ifdef USE_JOGSHUTTLE
    new JogManager(this);
#endif
725
    getMainTimeline()->setTimelineMenu(timelineClipMenu, compositionMenu, timelineMenu, guideMenu, timelineRulerMenu, actionCollection()->action(QStringLiteral("edit_guide")), timelineHeadersMenu, thumbsMenu);
726
    scmanager->slotCheckActiveScopes();
Nicolas Carion's avatar
format    
Nicolas Carion committed
727
    // m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
728
}
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
729

730
void MainWindow::slotThemeChanged(const QString &name)
731
{
732
    KSharedConfigPtr config = KSharedConfig::openConfig(name);
733
    QPalette plt = KColorScheme::createApplicationPalette(config);
734
    // qApp->setPalette(plt);
735
    // Required for qml palette change
736
    QGuiApplication::setPalette(plt);
737
738
739
740

    QColor background = plt.window().color();
    bool useDarkIcons = background.value() < 100;

741
742
    if (m_assetPanel) {
        m_assetPanel->updatePalette();
743
    }
744
745
746
747
748
749
750
751
    if (m_effectList2) {
        // Trigger a repaint to have icons adapted
        m_effectList2->reset();
    }
    if (m_transitionList2) {
        // Trigger a repaint to have icons adapted
        m_transitionList2->reset();
    }
Laurent Montel's avatar
Laurent Montel committed
752
753
754
755
756
757
    if (m_clipMonitor) {
        m_clipMonitor->setPalette(plt);
    }
    if (m_projectMonitor) {
        m_projectMonitor->setPalette(plt);
    }
758
759
    if (m_timelineTabs) {
        m_timelineTabs->setPalette(plt);
760
        getMainTimeline()->controller()->resetView();
761
762
763
    }
    if