Fix various focus issues with menus in timeline

parent 6ecb0c34
import QtQuick 2.6
import QtQuick.Controls 2.2
ComboBox {
}
......@@ -233,13 +233,16 @@ Rectangle {
onPressed: {
root.stopScrolling = true
if (mouse.button == Qt.RightButton) {
clipMenu.item.clipId = clipRoot.clipId
clipMenu.item.clipStatus = clipRoot.clipStatus
clipMenu.item.grouped = clipRoot.grouped
clipMenu.item.trackId = clipRoot.trackId
clipMenu.item.canBeAudio = clipRoot.canBeAudio
clipMenu.item.canBeVideo = clipRoot.canBeVideo
clipMenu.item.popup()
if (timeline.selection.indexOf(clipRoot.clipId) == -1) {
timeline.addSelection(clipRoot.clipId, true)
}
clipMenu.clipId = clipRoot.clipId
clipMenu.clipStatus = clipRoot.clipStatus
clipMenu.grouped = clipRoot.grouped
clipMenu.trackId = clipRoot.trackId
clipMenu.canBeAudio = clipRoot.canBeAudio
clipMenu.canBeVideo = clipRoot.canBeVideo
clipMenu.popup()
}
}
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)
......
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Controls 1.4
import com.enums 1.0
Menu {
......@@ -10,6 +10,11 @@ Menu {
property bool grouped
property bool canBeAudio
property bool canBeVideo
onAboutToHide: {
timeline.ungrabHack()
}
MenuItem {
text: i18n('Copy')
onTriggered: root.copiedClip = clipId
......@@ -27,7 +32,7 @@ Menu {
MenuItem {
text: i18n('Edit Duration')
onTriggered: {
clipMenu.close()
//clipMenu.close()
timeline.editItemDuration(clipId)
}
}
......
import QtQuick 2.6
import QtQuick.Controls 1.4
import com.enums 1.0
Menu {
id: clipMenu
property int clipId
property int clipStatus
property int trackId
property bool grouped
property bool canBeAudio
property bool canBeVideo
MenuItem {
text: i18n('Copy')
onTriggered: root.copiedClip = clipId
}
MenuItem {
visible: !grouped && timeline.selection.length > 1
text: i18n('Group')
onTriggered: timeline.triggerAction('group_clip')
}
MenuItem {
visible: grouped
text: i18n('Ungroup')
onTriggered: timeline.unGroupSelection(clipId)
}
MenuItem {
text: i18n('Edit Duration')
onTriggered: {
//clipMenu.close()
timeline.editItemDuration(clipId)
}
}
MenuItem {
visible: root.copiedClip != -1 && root.copiedClip != clipId
text: i18n('Paste Effects')
onTriggered: timeline.pasteEffects(clipId, root.copiedClip)
}
MenuSeparator {
visible: true
}
MenuItem {
text: i18n('Split Audio')
onTriggered: timeline.splitAudio(clipId)
visible: !grouped && canBeAudio && clipStatus == ClipState.VideoOnly
}
MenuItem {
text: i18n('Split Video')
onTriggered: timeline.splitVideo(clipId)
visible: !grouped && canBeVideo && clipStatus == ClipState.AudioOnly
}
MenuItem {
text: i18n('Remove')
onTriggered: timeline.triggerAction('delete_timeline_clip')
}
MenuItem {
visible: true
text: i18n('Extract')
onTriggered: timeline.extract(clipId)
}
MenuSeparator {
visible: true
}
MenuItem {
visible: true
text: i18n('Change Speed')
onTriggered: {
clipMenu.close()
timeline.changeItemSpeed(clipId, -1)
}
}
MenuItem {
text: i18n('Clip in Project Bin')
onTriggered: timeline.triggerAction('clip_in_project_tree')
}
MenuItem {
visible: true
text: i18n('Split At Playhead')
onTriggered: timeline.triggerAction('cut_timeline_clip')
}
MenuItem {
visible: true
text: clipStatus != ClipState.Disabled ? i18n('Disable clip') : i18n('Enable clip')
onTriggered: timeline.switchEnableState(clipId)
}
AssetMenu {
title: i18n('Insert an effect...')
menuModel: effectModel
onAssetSelected: {
timeline.addEffectToClip(assetId, clipId)
}
}
AssetMenu {
title: i18n('Insert a composition...')
menuModel: transitionModel
isTransition: true
onAssetSelected: {
timeline.addCompositionToClip(assetId, clipId)
}
}
}
......@@ -215,14 +215,14 @@ Item {
onPressed: {
root.stopScrolling = true
compositionRoot.forceActiveFocus();
/*if (!compositionRoot.selected) {
compositionRoot.clicked(compositionRoot, false)
}*/
if (mouse.button == Qt.RightButton) {
compositionMenu.item.clipId = compositionRoot.clipId
compositionMenu.item.grouped = compositionRoot.grouped
compositionMenu.item.trackId = compositionRoot.trackId
compositionMenu.item.popup()
if (timeline.selection.indexOf(compositionRoot.clipId) == -1) {
timeline.addSelection(compositionRoot.clipId, true)
}
compositionMenu.clipId = compositionRoot.clipId
compositionMenu.grouped = compositionRoot.grouped
compositionMenu.trackId = compositionRoot.trackId
compositionMenu.popup()
}
}
onEntered: {
......
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Controls 1.4
Menu {
id: compositionMenu
......@@ -8,6 +8,10 @@ Menu {
property int trackId
property bool grouped
onAboutToHide: {
timeline.ungrabHack()
}
function show() {
//mergeItem.visible = timeline.mergeClipWithNext(trackIndex, index, true)
popup()
......@@ -25,7 +29,7 @@ Menu {
MenuItem {
text: i18n('Edit Duration')
onTriggered: {
compositionMenu.close()
//compositionMenu.close()
timeline.editItemDuration(clipId)
}
}
......
import QtQuick 2.6
import QtQuick.Controls 1.4
Menu {
id: compositionMenu
property int clipId
property int clipStatus
property int trackId
property bool grouped
function show() {
//mergeItem.visible = timeline.mergeClipWithNext(trackIndex, index, true)
popup()
}
MenuItem {
visible: !grouped && timeline.selection.length > 1
text: i18n('Group')
onTriggered: timeline.groupSelection()
}
MenuItem {
visible: grouped
text: i18n('Ungroup')
onTriggered: timeline.unGroupSelection(clipId)
}
MenuItem {
text: i18n('Edit Duration')
onTriggered: {
//compositionMenu.close()
timeline.editItemDuration(clipId)
}
}
MenuItem {
visible: true
text: i18n('Copy')
onTriggered: root.copiedClip = clipId
}
MenuItem {
text: i18n('Remove')
onTriggered: timeline.triggerAction('delete_timeline_clip')
}
MenuSeparator {
visible: true
}
MenuItem {
visible: true
text: i18n('Split At Playhead (S)')
onTriggered: timeline.triggerAction('cut_timeline_clip')
}
}
......@@ -23,21 +23,11 @@ Rectangle {
id: fontMetrics
font.family: "Arial"
}
Loader {
source: 'CheckQuickVersion.qml'
property bool validMenu: item.editable == false
ClipMenu {
id: clipMenu
onLoaded: {
source = validMenu ? 'ClipMenu.qml' : 'ClipMenuOld.qml'
}
}
Loader {
source: 'CheckQuickVersion.qml'
property bool validMenu: item.editable == false
CompositionMenu {
id: compositionMenu
onLoaded: {
source = validMenu ? 'CompositionMenu.qml' : 'CompositionMenuOld.qml'
}
}
function moveSelectedTrack(offset) {
......
......@@ -131,11 +131,18 @@ void TimelineController::removeSelection(int newSelection)
emit selected(nullptr);
}
void TimelineController::addSelection(int newSelection)
void TimelineController::addSelection(int newSelection, bool clear)
{
if (m_selection.selectedItems.contains(newSelection)) {
return;
}
if (clear) {
if (m_model->m_temporarySelectionGroup >= 0) {
m_model->m_groups->destructGroupItem(m_model->m_temporarySelectionGroup);
m_model->m_temporarySelectionGroup = -1;
}
m_selection.selectedItems.clear();
}
m_selection.selectedItems << newSelection;
std::unordered_set<int> ids;
ids.insert(m_selection.selectedItems.cbegin(), m_selection.selectedItems.cend());
......
......@@ -78,7 +78,7 @@ public:
Q_INVOKABLE void removeSelection(int newSelection);
/** @brief Add a clip id to current selection
*/
Q_INVOKABLE void addSelection(int newSelection);
Q_INVOKABLE void addSelection(int newSelection, bool clear = false);
/** @brief Edit an item's in/out points with a dialog
*/
Q_INVOKABLE void editItemDuration(int itemId);
......@@ -479,6 +479,7 @@ signals:
void renderedChunksChanged();
void workingPreviewChanged();
void useRulerChanged();
Q_INVOKABLE void ungrabHack();
};
#endif
......@@ -81,6 +81,7 @@ TimelineWidget::TimelineWidget(QWidget *parent)
m_effectsProxyModel->sort(0, Qt::AscendingOrder);
m_proxy = new TimelineController(this);
connect(m_proxy, &TimelineController::zoneMoved, this, &TimelineWidget::zoneMoved);
connect(m_proxy, &TimelineController::ungrabHack, this, &TimelineWidget::slotUngrabHack);
setResizeMode(QQuickWidget::SizeRootObjectToView);
m_thumbnailer = new ThumbnailProvider;
engine()->addImageProvider(QStringLiteral("thumbnail"), m_thumbnailer);
......@@ -174,3 +175,12 @@ QPoint TimelineWidget::getTracksCount() const
{
return m_proxy->getTracksCount();
}
void TimelineWidget::slotUngrabHack()
{
// Workaround bug: https://bugreports.qt.io/browse/QTBUG-59044
// https://phabricator.kde.org/D5515
if (quickWindow() && quickWindow()->mouseGrabberItem()) {
quickWindow()->mouseGrabberItem()->ungrabMouse();
}
}
......@@ -61,6 +61,9 @@ public slots:
/* @brief Favorite transitions have changed, reload model for context menu */
void updateTransitionFavorites();
private slots:
void slotUngrabHack();
private:
ThumbnailProvider *m_thumbnailer;
TimelineController *m_proxy;
......
......@@ -28,10 +28,7 @@
<file alias="KeyframeView.qml">timeline2/view/qml/KeyframeView.qml</file>
<file alias="Composition.qml">timeline2/view/qml/Composition.qml</file>
<file alias="ClipMenu.qml">timeline2/view/qml/ClipMenu.qml</file>
<file alias="ClipMenuOld.qml">timeline2/view/qml/ClipMenuOld.qml</file>
<file alias="CheckQuickVersion.qml">timeline2/view/qml/CheckQuickVersion.qml</file>
<file alias="CompositionMenu.qml">timeline2/view/qml/CompositionMenu.qml</file>
<file alias="CompositionMenuOld.qml">timeline2/view/qml/CompositionMenuOld.qml</file>
<file alias="PulsingAnimation.qml">timeline2/view/qml/PulsingAnimation.qml</file>
<file alias="CornerSelectionShadow.qml">timeline2/view/qml/CornerSelectionShadow.qml</file>
<file alias="Timeline.js">timeline2/view/qml/Timeline.js</file>
......
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