Commit fd468156 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Switch timeline clip context menu to QWidget instead of Qml.

Fixes the "cannot edit text" issue on Windows and makes keyboard shortcuts appear again in menu
parent ddc4751f
Pipeline #13779 passed with stage
in 16 minutes and 4 seconds
......@@ -417,7 +417,7 @@ void AssetPanel::slotCheckWheelEventFilter()
m_effectStackWidget->blockWheenEvent(blockWheel);
}
void AssetPanel::assetPanelWarning(const QString service, const QString id, const QString message)
void AssetPanel::assetPanelWarning(const QString service, const QString /*id*/, const QString message)
{
QString finalMessage;
if (!service.isEmpty() && EffectsRepository::get()->exists(service)) {
......
......@@ -503,6 +503,26 @@ void MainWindow::init()
loadGenerators();
loadDockActions();
loadClipActions();
QMenu *timelineMenu = new QMenu(this);
timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_paste")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("group_clip")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("ungroup_clip")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_duration")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("clip_split")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("clip_switch")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("delete_timeline_clip")));
QMenu *markerMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this));
timelineMenu->addMenu(markerMenu);
timelineMenu->addAction(actionCollection()->action(QStringLiteral("set_audio_align_ref")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("align_audio")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_speed")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("clip_in_project_tree")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("cut_timeline_clip")));
QMenu *openGLMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("qt_opengl"), this));
#if defined(Q_OS_WIN)
connect(openGLMenu, &QMenu::triggered, [&](QAction *ac) {
......@@ -640,6 +660,7 @@ void MainWindow::init()
#ifdef USE_JOGSHUTTLE
new JogManager(this);
#endif
getMainTimeline()->setTimelineMenu(timelineMenu);
scmanager->slotCheckActiveScopes();
// m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
}
......@@ -1401,7 +1422,7 @@ void MainWindow::setupActions()
QAction *switchEnable = addAction(QStringLiteral("clip_switch"), i18n("Disable Clip"), this, SLOT(slotSwitchClip()),
QIcon(), QKeySequence(), clipActionCategory);
// "S" will be handled specifically to change the action name depending on current selection
// "W" will be handled specifically to change the action name depending on current selection
switchEnable->setData('W');
switchEnable->setEnabled(false);
......@@ -1458,7 +1479,7 @@ void MainWindow::setupActions()
groupClip->setEnabled(false);
QAction *ungroupClip = addAction(QStringLiteral("ungroup_clip"), i18n("Ungroup Clips"), this, SLOT(slotUnGroupClips()),
QIcon::fromTheme(QStringLiteral("object-ungroup")), Qt::CTRL + Qt::SHIFT + Qt::Key_G, clipActionCategory);
QIcon::fromTheme(QStringLiteral("object-ungroup")), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G), clipActionCategory);
// "U" as data means this action should only be available if selection is a group
ungroupClip->setData('U');
ungroupClip->setEnabled(false);
......@@ -2308,11 +2329,8 @@ void MainWindow::slotAddClipMarker()
std::shared_ptr<ProjectClip> clip(nullptr);
GenTime pos;
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->addMarker(selectedClip);
return;
}
getMainTimeline()->controller()->addMarker();
return;
} else {
clip = m_clipMonitor->currentController();
pos = GenTime(m_clipMonitor->position(), pCore->getCurrentFps());
......@@ -2330,11 +2348,8 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion)
std::shared_ptr<ProjectClip> clip(nullptr);
GenTime pos;
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->deleteMarker(selectedClip);
return;
}
getMainTimeline()->controller()->deleteMarker();
return;
} else {
clip = m_clipMonitor->currentController();
pos = GenTime(m_clipMonitor->position(), pCore->getCurrentFps());
......@@ -2362,11 +2377,8 @@ void MainWindow::slotDeleteAllClipMarkers()
{
std::shared_ptr<ProjectClip> clip(nullptr);
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->deleteAllMarkers(selectedClip);
return;
}
getMainTimeline()->controller()->deleteAllMarkers();
return;
} else {
clip = m_clipMonitor->currentController();
}
......@@ -2386,11 +2398,8 @@ void MainWindow::slotEditClipMarker()
std::shared_ptr<ProjectClip> clip(nullptr);
GenTime pos;
if (m_projectMonitor->isActive()) {
int selectedClip = getMainTimeline()->controller()->getMainSelectedItem();
if (selectedClip > -1) {
getMainTimeline()->controller()->editMarker(selectedClip);
return;
}
getMainTimeline()->controller()->editMarker();
return;
} else {
clip = m_clipMonitor->currentController();
pos = GenTime(m_clipMonitor->position(), pCore->getCurrentFps());
......@@ -2434,7 +2443,7 @@ void MainWindow::slotAddMarkerGuideQuickly()
getMainTimeline()->controller()->switchGuide();
} else {
// Add marker to main clip
getMainTimeline()->controller()->addQuickMarker(selectedClip);
getMainTimeline()->controller()->addQuickMarker();
}
}
}
......@@ -3047,22 +3056,12 @@ void MainWindow::slotSwitchClip()
void MainWindow::slotSetAudioAlignReference()
{
// TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->setAudioAlignReference();
}
*/
getMainTimeline()->controller()->setAudioRef();
}
void MainWindow::slotAlignAudio()
{
// TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->alignAudio();
}
*/
getMainTimeline()->controller()->alignAudio();
}
void MainWindow::slotUpdateClipType(QAction *action)
......
......@@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "timelineitemmodel.hpp"
#include "trackmodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
......@@ -600,8 +601,26 @@ bool TimelineFunctions::switchEnableState(const std::shared_ptr<TimelineItemMode
break;
}
}
// Update action name since clip will be switched
int id = *selection.begin();
Fun local_redo = []() { return true; };
Fun local_undo = []() { return true; };
if (timeline->isClip(id)) {
bool disabled = timeline->m_allClips[id]->clipState() == PlaylistState::Disabled;
QAction *action = pCore->window()->actionCollection()->action(QStringLiteral("clip_switch"));
local_redo = [disabled, action]() {
action->setText(disabled ? i18n("Enable clip") : i18n("Disable clip"));
return true;
};
local_undo = [disabled, action]() {
action->setText(disabled ? i18n("Disable clip") : i18n("Enable clip"));
return true;
};
}
if (result) {
pCore->pushUndo(undo, redo, disable ? i18n("Disable clip") : i18n("Enable clip"));
local_redo();
UPDATE_UNDO_REDO_NOLOCK(local_redo, local_undo, undo, redo);
pCore->pushUndo(undo, redo, disable ? i18n("Disable clip") : i18n("Enable clip"));
}
return result;
}
......
......@@ -248,14 +248,9 @@ Rectangle {
if (timeline.selection.indexOf(clipRoot.clipId) == -1) {
controller.requestAddToSelection(clipRoot.clipId, true)
}
clipMenu.clipId = clipRoot.clipId
clipMenu.clipStatus = clipRoot.clipStatus
clipMenu.clipFrame = Math.round(mouse.x / timeline.scaleFactor)
clipMenu.grouped = clipRoot.grouped
clipMenu.trackId = clipRoot.trackId
clipMenu.canBeAudio = clipRoot.canBeAudio
clipMenu.canBeVideo = clipRoot.canBeVideo
clipMenu.popup()
root.mainItemId = clipRoot.clipId
root.clipFrame = Math.round(mouse.x / timeline.scaleFactor)
root.showClipMenu()
}
}
Keys.onShortcutOverride: event.accepted = clipRoot.isGrabbed && (event.key === Qt.Key_Left || event.key === Qt.Key_Right || event.key === Qt.Key_Up || event.key === Qt.Key_Down || event.key === Qt.Key_Escape)
......
......@@ -19,6 +19,7 @@ Rectangle {
signal clipClicked()
signal mousePosChanged(int position)
signal showClipMenu()
signal zoomIn(bool onMouse)
signal zoomOut(bool onMouse)
signal processingDrag(bool dragging)
......@@ -27,9 +28,7 @@ Rectangle {
id: fontMetrics
font: smallFont
}
ClipMenu {
id: clipMenu
}
CompositionMenu {
id: compositionMenu
}
......@@ -236,6 +235,8 @@ Rectangle {
property color lockedColor: timeline.lockedColor
property color selectionColor: timeline.selectionColor
property color groupColor: timeline.groupColor
property int mainItemId: -1
property int clipFrame: 0
property int clipBeingDroppedId: -1
property string clipBeingDroppedData
property int droppedPosition: -1
......@@ -1205,9 +1206,12 @@ Rectangle {
}
if (clickAccepted && dragProxy.draggedItem != -1) {
focus = true;
root.mainItemId = dragProxy.draggedItem
dragProxy.masterObject.originalX = dragProxy.masterObject.x
dragProxy.masterObject.originalTrackId = dragProxy.masterObject.trackId
dragProxy.masterObject.forceActiveFocus();
} else {
root.mainItemId = -1
}
} else {
mouse.accepted = false
......
......@@ -763,6 +763,9 @@ void TimelineController::setOutPoint()
void TimelineController::editMarker(int cid, int position)
{
if (cid == -1) {
cid = m_root->property("mainItemId").toInt();
}
Q_ASSERT(m_model->isClip(cid));
double speed = m_model->getClipSpeed(cid);
if (position == -1) {
......@@ -785,6 +788,9 @@ void TimelineController::editMarker(int cid, int position)
void TimelineController::addMarker(int cid, int position)
{
if (cid == -1) {
cid = m_root->property("mainItemId").toInt();
}
Q_ASSERT(m_model->isClip(cid));
double speed = m_model->getClipSpeed(cid);
if (position == -1) {
......@@ -803,14 +809,17 @@ void TimelineController::addMarker(int cid, int position)
void TimelineController::addQuickMarker(int cid, int position)
{
if (cid == -1) {
cid = m_root->property("mainItemId").toInt();
}
Q_ASSERT(m_model->isClip(cid));
double speed = m_model->getClipSpeed(cid);
if (position == -1) {
// Calculate marker position relative to timeline cursor
position = pCore->getTimelinePosition() - m_model->getClipPosition(cid) + m_model->getClipIn(cid);
position = pCore->getTimelinePosition() - m_model->getClipPosition(cid);
position = position * speed;
}
if (position < (m_model->getClipIn(cid) * speed) || position > (m_model->getClipIn(cid) * speed + m_model->getClipPlaytime(cid))) {
if (position < (m_model->getClipIn(cid) * speed) || position > ((m_model->getClipIn(cid) + m_model->getClipPlaytime(cid) * speed))) {
pCore->displayMessage(i18n("Cannot find clip to edit marker"), InformationMessage, 500);
return;
}
......@@ -822,6 +831,9 @@ void TimelineController::addQuickMarker(int cid, int position)
void TimelineController::deleteMarker(int cid, int position)
{
if (cid == -1) {
cid = m_root->property("mainItemId").toInt();
}
Q_ASSERT(m_model->isClip(cid));
double speed = m_model->getClipSpeed(cid);
if (position == -1) {
......@@ -840,6 +852,9 @@ void TimelineController::deleteMarker(int cid, int position)
void TimelineController::deleteAllMarkers(int cid)
{
if (cid == -1) {
cid = m_root->property("mainItemId").toInt();
}
Q_ASSERT(m_model->isClip(cid));
std::shared_ptr<ProjectClip> clip = pCore->bin()->getBinClip(getClipBinId(cid));
clip->getMarkerModel()->removeAllMarkers();
......@@ -1583,8 +1598,11 @@ void TimelineController::invalidateZone(int in, int out)
void TimelineController::changeItemSpeed(int clipId, double speed)
{
if (clipId == -1) {
/*if (clipId == -1) {
clipId = getMainSelectedItem(false, true);
}*/
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
if (clipId == -1) {
pCore->displayMessage(i18n("No item to edit"), InformationMessage, 500);
......@@ -1817,11 +1835,20 @@ void TimelineController::switchEnableState(std::unordered_set<int> selection)
selection = m_model->getCurrentSelection();
//clipId = getMainSelectedItem(false, false);
}
if (selection.empty()) {
return;
}
TimelineFunctions::switchEnableState(m_model, selection);
}
void TimelineController::addCompositionToClip(const QString &assetId, int clipId, int offset)
{
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
if (offset == -1) {
offset = m_root->property("clipFrame").toInt();
}
int track = m_model->getClipTrackId(clipId);
int compoId = -1;
if (assetId.isEmpty()) {
......@@ -1841,6 +1868,9 @@ void TimelineController::addCompositionToClip(const QString &assetId, int clipId
void TimelineController::addEffectToClip(const QString &assetId, int clipId)
{
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
qDebug() << "/// ADDING ASSET: " << assetId;
m_model->addClipEffect(clipId, assetId);
}
......@@ -1872,6 +1902,9 @@ void TimelineController::splitVideo(int clipId)
void TimelineController::setAudioRef(int clipId)
{
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
m_audioRef = clipId;
std::unique_ptr<AudioEnvelope> envelope(new AudioEnvelope(getClipBinId(clipId), clipId));
m_audioCorrelator.reset(new AudioCorrelation(std::move(envelope)));
......@@ -1888,6 +1921,9 @@ void TimelineController::setAudioRef(int clipId)
void TimelineController::alignAudio(int clipId)
{
// find other clip
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
if (m_audioRef == -1 || m_audioRef == clipId) {
pCore->displayMessage(i18n("Set audio reference before attempting to align"), InformationMessage, 500);
return;
......@@ -2113,9 +2149,9 @@ double TimelineController::fps() const
void TimelineController::editItemDuration(int id)
{
if (id == -1) {
id = getMainSelectedItem(false, true);
id = m_root->property("mainItemId").toInt(); //getMainSelectedItem(false, true);
}
if (id == -1) {
if (id == -1 || !m_model->isItem(id)) {
pCore->displayMessage(i18n("No item to edit"), InformationMessage, 500);
return;
}
......@@ -2231,9 +2267,9 @@ void TimelineController::updateClipActions()
bool enableAction = true;
const QChar actionData = act->data().toChar();
if (actionData == QLatin1Char('G')) {
enableAction = isInSelection(item);
enableAction = isInSelection(item) && m_model->getCurrentSelection().size() > 1;
} else if (actionData == QLatin1Char('U')) {
enableAction = isInSelection(item) || (m_model->m_groups->isInGroup(item) && !isInSelection(item));
enableAction = m_model->m_groups->isInGroup(item);
} else if (actionData == QLatin1Char('A')) {
enableAction = clip && clip->clipState() == PlaylistState::AudioOnly;
} else if (actionData == QLatin1Char('V')) {
......
......@@ -252,19 +252,19 @@ public:
Q_INVOKABLE void unGroupSelection(int cid = -1);
/* @brief Ask for edit marker dialog
*/
Q_INVOKABLE void editMarker(int cid, int position = -1);
Q_INVOKABLE void editMarker(int cid = -1, int position = -1);
/* @brief Ask for marker add dialog
*/
Q_INVOKABLE void addMarker(int cid, int position = -1);
Q_INVOKABLE void addMarker(int cid = -1, int position = -1);
/* @brief Ask for quick marker add (without dialog)
*/
Q_INVOKABLE void addQuickMarker(int cid, int position = -1);
Q_INVOKABLE void addQuickMarker(int cid = -1, int position = -1);
/* @brief Ask for marker delete
*/
Q_INVOKABLE void deleteMarker(int cid, int position = -1);
Q_INVOKABLE void deleteMarker(int cid = -1, int position = -1);
/* @brief Ask for all markers delete
*/
Q_INVOKABLE void deleteAllMarkers(int cid);
Q_INVOKABLE void deleteAllMarkers(int cid = -1);
/* @brief Ask for edit timeline guide dialog
*/
Q_INVOKABLE void editGuide(int frame = -1);
......@@ -335,8 +335,8 @@ public:
/* @brief If clip is enabled, disable, otherwise enable
*/
Q_INVOKABLE void switchEnableState(std::unordered_set<int> selection = {});
Q_INVOKABLE void addCompositionToClip(const QString &assetId, int clipId, int offset);
Q_INVOKABLE void addEffectToClip(const QString &assetId, int clipId);
Q_INVOKABLE void addCompositionToClip(const QString &assetId, int clipId = -1, int offset = -1);
Q_INVOKABLE void addEffectToClip(const QString &assetId, int clipId = -1);
Q_INVOKABLE void requestClipCut(int clipId, int position);
......@@ -344,8 +344,8 @@ public:
Q_INVOKABLE void splitAudio(int clipId);
Q_INVOKABLE void splitVideo(int clipId);
Q_INVOKABLE void setAudioRef(int clipId);
Q_INVOKABLE void alignAudio(int clipId);
Q_INVOKABLE void setAudioRef(int clipId = -1);
Q_INVOKABLE void alignAudio(int clipId = -1);
Q_INVOKABLE bool endFakeMove(int clipId, int position, bool updateView, bool logUndo, bool invalidateTimeline);
Q_INVOKABLE int getItemMovingTrack(int itemId) const;
......
......@@ -48,6 +48,7 @@
#include <QQmlEngine>
#include <QQuickItem>
#include <QUuid>
#include <QMenu>
#include <QFontDatabase>
#include <QSortFilterProxyModel>
......@@ -86,6 +87,8 @@ TimelineWidget::TimelineWidget(QWidget *parent)
setVisible(false);
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setFocusPolicy(Qt::StrongFocus);
m_favEffects = new QMenu(i18n("Insert an effect..."), this);
m_favCompositions = new QMenu(i18n("Insert a composition..."), this);
}
TimelineWidget::~TimelineWidget()
......@@ -95,21 +98,54 @@ TimelineWidget::~TimelineWidget()
void TimelineWidget::updateEffectFavorites()
{
rootContext()->setContextProperty("effectModel", sortedItems(KdenliveSettings::favorite_effects(), false));
const QMap<QString, QString> effects = sortedItems(KdenliveSettings::favorite_effects(), false);
QMapIterator<QString, QString> i(effects);
m_favEffects->clear();
while (i.hasNext()) {
i.next();
QAction *ac = m_favEffects->addAction(i.key());
ac->setData(i.value());
}
const QStringList effs = effects.values();
rootContext()->setContextProperty("effectModel",effs);
}
void TimelineWidget::updateTransitionFavorites()
{
rootContext()->setContextProperty("transitionModel", sortedItems(KdenliveSettings::favorite_transitions(), true));
const QMap<QString, QString> effects = sortedItems(KdenliveSettings::favorite_transitions(), true);
QMapIterator<QString, QString> i(effects);
m_favCompositions->clear();
while (i.hasNext()) {
i.next();
QAction *ac = m_favCompositions->addAction(i.key());
ac->setData(i.value());
}
const QStringList trans = effects.values();
rootContext()->setContextProperty("transitionModel", trans);
}
const QStringList TimelineWidget::sortedItems(const QStringList &items, bool isTransition)
const QMap<QString, QString> TimelineWidget::sortedItems(const QStringList &items, bool isTransition)
{
QMap<QString, QString> sortedItems;
for (const QString &effect : items) {
sortedItems.insert(m_proxy->getAssetName(effect, isTransition), effect);
}
return sortedItems.values();
return sortedItems;
}
void TimelineWidget::setTimelineMenu(QMenu *menu)
{
m_timelineClipMenu = menu;
updateEffectFavorites();
updateTransitionFavorites();
connect(m_favEffects, &QMenu::triggered, [&] (QAction *ac) {
m_proxy->addEffectToClip(ac->data().toString());
});
connect(m_favCompositions, &QMenu::triggered, [&] (QAction *ac) {
m_proxy->addCompositionToClip(ac->data().toString());
});
m_timelineClipMenu->addMenu(m_favEffects);
m_timelineClipMenu->addMenu(m_favCompositions);
}
void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, MonitorProxy *proxy)
......@@ -126,13 +162,15 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
// leaking from one project to another because of qml's image caching
rootContext()->setContextProperty("documentId", QUuid::createUuid());
rootContext()->setContextProperty("miniFont", QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
rootContext()->setContextProperty("transitionModel", sortedItems(KdenliveSettings::favorite_transitions(), true)); // m_transitionProxyModel.get());
// rootContext()->setContextProperty("effectModel", m_effectsProxyModel.get());
rootContext()->setContextProperty("effectModel", sortedItems(KdenliveSettings::favorite_effects(), false));
rootContext()->setContextProperty("audiorec", pCore->getAudioDevice());
rootContext()->setContextProperty("guidesModel", pCore->projectManager()->current()->getGuideModel().get());
rootContext()->setContextProperty("clipboard", new ClipboardProxy(this));
rootContext()->setContextProperty("smallFont", QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
const QStringList effs = sortedItems(KdenliveSettings::favorite_effects(), false).values();
const QStringList trans = sortedItems(KdenliveSettings::favorite_transitions(), true).values();
rootContext()->setContextProperty("transitionModel", trans);
rootContext()->setContextProperty("effectModel",effs);
setSource(QUrl(QStringLiteral("qrc:/qml/timeline.qml")));
connect(rootObject(), SIGNAL(mousePosChanged(int)), pCore->window(), SLOT(slotUpdateMousePosition(int)));
connect(rootObject(), SIGNAL(zoomIn(bool)), pCore->window(), SLOT(slotZoomIn(bool)));
......@@ -140,6 +178,7 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
connect(rootObject(), SIGNAL(processingDrag(bool)), pCore->window(), SIGNAL(enableUndo(bool)));
connect(m_proxy, &TimelineController::seeked, proxy, &MonitorProxy::setPosition);
rootObject()->setProperty("dar", pCore->getCurrentDar());
connect(rootObject(), SIGNAL(showClipMenu()), this, SLOT(showClipMenu()));
m_proxy->setRoot(rootObject());
setVisible(true);
loading = false;
......@@ -149,9 +188,18 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
void TimelineWidget::mousePressEvent(QMouseEvent *event)
{
emit focusProjectMonitor();
m_clickPos = event->globalPos();
QQuickWidget::mousePressEvent(event);
}
void TimelineWidget::showClipMenu()
{
m_timelineClipMenu->popup(m_clickPos);
connect(m_timelineClipMenu, &QMenu::aboutToHide, [this]() {
slotUngrabHack();
});
}
void TimelineWidget::slotChangeZoom(int value, bool zoomOnMouse)
{
double pixelScale = QFontMetrics(font()).maxWidth() * 2;
......
......@@ -53,6 +53,8 @@ public:
int zoomForScale(double value) const;
/* @brief Give keyboard focus to timeline qml */
void focusTimeline();
/** @brief Initiate timeline clip context menu */
void setTimelineMenu(QMenu *menu);
bool loading;
protected:
......@@ -69,9 +71,13 @@ public slots:
private slots:
void slotUngrabHack();
void showClipMenu();
private:
TimelineController *m_proxy;
QMenu *m_timelineClipMenu;
QMenu *m_favEffects;
QMenu *m_favCompositions;
static const int comboScale[];
std::shared_ptr<AssetTreeModel> m_transitionModel;
std::unique_ptr<AssetFilter> m_transitionProxyModel;
......@@ -83,7 +89,8 @@ private:
/* @brief Keep last scroll position before fit to restore it on second click */
int m_scrollPos;
/* @brief Returns an alphabetically sorted list of favorite effects or transitions */
const QStringList sortedItems(const QStringList &items, bool isTransition);
const QMap<QString, QString> sortedItems(const QStringList &items, bool isTransition);
QPoint m_clickPos;
signals:
void focusProjectMonitor();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment