File indexing completed on 2024-04-21 04:51:40

0001 /*
0002     SPDX-FileCopyrightText: 2014 Till Theato <root@ttill.de>
0003 
0004     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 
0006     This file is part of Kdenlive. See www.kdenlive.org.
0007 */
0008 
0009 #include "jogmanager.h"
0010 #include "core.h"
0011 #include "jogaction.h"
0012 #include "jogshuttle.h"
0013 #include "jogshuttleconfig.h"
0014 #include "kdenlivesettings.h"
0015 #include "mainwindow.h"
0016 
0017 JogManager::JogManager(QObject *parent)
0018     : QObject(parent)
0019 
0020 {
0021     slotConfigurationChanged();
0022 
0023     connect(pCore->window(), &MainWindow::configurationChanged, this, &JogManager::slotConfigurationChanged);
0024 }
0025 
0026 void JogManager::slotConfigurationChanged()
0027 {
0028     delete m_shuttleAction;
0029     m_shuttleAction = nullptr;
0030     delete m_shuttle;
0031     m_shuttle = nullptr;
0032 
0033     if (KdenliveSettings::enableshuttle()) {
0034         m_shuttle = new JogShuttle(JogShuttle::canonicalDevice(KdenliveSettings::shuttledevice()));
0035         m_shuttleAction = new JogShuttleAction(m_shuttle, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
0036 
0037         connect(m_shuttleAction, &JogShuttleAction::action, this, &JogManager::slotDoAction);
0038     }
0039 }
0040 
0041 void JogManager::slotDoAction(const QString &actionName)
0042 {
0043     QAction *action = pCore->window()->actionCollection()->action(actionName);
0044     if (!action) {
0045         fprintf(stderr, "%s", QStringLiteral("shuttle action '%1' unknown\n").arg(actionName).toLatin1().constData());
0046         return;
0047     }
0048     action->trigger();
0049 }