Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ui/qml/xstudio/application/panels/media/XsMediaPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ Item{
propertyNames: ["is_list_view", "cellSize"]
}

signal frameSelectedMedia()

// object in which to store container scroll positions
property var scrollKeeper
Component.onCompleted: scrollKeeper = new Object()


/**************************************************************
HotKeys
****************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ XsGridView {

// what row is the on-screen media?
var row = mediaListModelData.getRowWithMatchingRoleData(onScreenMediaUuid, "actorUuidRole")

return autoScrollToRow(row)
}

function autoScrollToSelectedMedia() {
if (visible && mediaSelectionModel.selectedIndexes.length) {
var row = mediaSelectionModel.selectedIndexes[0].row
return autoScrollToRow(row)
}
}

function autoScrollToRow(row) {
if (row == -1) return

var num_cols = Math.floor(width/cellWidth) > 0 ? Math.floor(width/cellWidth) : 1
Expand All @@ -66,7 +78,14 @@ XsGridView {

autoScrollAnimator.to = Math.max(originY, Math.min(mid - mediaList.height/2, mediaList.contentHeight - mediaList.height))
autoScrollAnimator.running = true
}

Connections {
target: panel
enabled: visible
function onFrameSelectedMedia() {
autoScrollToSelectedMedia()
}
}

XsLabel {
Expand Down Expand Up @@ -301,4 +320,8 @@ XsGridView {
if (!running && mediaList.contentY > originY) start()
}
}
}

XsMediaScrollKeeper {
prefix: "G"
}
}
22 changes: 22 additions & 0 deletions ui/qml/xstudio/application/panels/media/list_view/XsMediaList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ XsListView {

// what row is the on-screen media?
var row = mediaListModelData.getRowWithMatchingRoleData(onScreenMediaUuid, "actorUuidRole")

return autoScrollToRow(row)
}

function autoScrollToSelectedMedia() {
if (visible && mediaSelectionModel.selectedIndexes.length) {
var row = mediaSelectionModel.selectedIndexes[0].row
return autoScrollToRow(row)
}
}

function autoScrollToRow(row) {
if (row == -1) return

// what is the Y coordinate of the media item within the media list?
Expand All @@ -100,7 +112,14 @@ XsListView {
autoScrollAnimator.to = Math.max(originY, Math.min(mid - mediaList.height/2, mediaList.contentHeight - mediaList.height))

autoScrollAnimator.running = true
}

Connections {
target: panel
enabled: visible
function onFrameSelectedMedia() {
autoScrollToSelectedMedia()
}
}

XsMediaListMouseArea {
Expand Down Expand Up @@ -337,4 +356,7 @@ XsListView {
}
}

XsMediaScrollKeeper {
prefix: "L"
}
}
10 changes: 10 additions & 0 deletions ui/qml/xstudio/application/panels/media/widgets/XsMediaHotKeys.qml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,16 @@ XsHotkeyArea {
componentName: "Media List"
}

XsHotkey {
id: frame_hotkey
sequence: "F"
name: "Frame Selected"
description: "Frame Selected"
context: hotkey_area.context
onActivated: frameSelectedMedia()
componentName: "Media List"
}

// add hotkeys for setting flag colours
Repeater {
model: flagColours.length
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: Apache-2.0
import QtQuick

import xStudio 1.0

Item {
id: widget
property string prefix: ""

//
// Here is the logic to remember the scrolled position per container.
// This assumes that somewhere in the parent hierarchy is a dictionary
// property named scrollKeeper into which the scroll data is kept.
//

// machanism to stash the contentY before it gets erased
// when a new container is selected
property real storeContentY: 0
Connections {
target: mediaListModelData
enabled: visible
function onModelAboutToBeReset() {
storeContentY = contentY
}
}

// machanism to store and restore the scroll position
// whenever the current container changes
Connections {
target: sessionSelectionModel
enabled: visible
function onCurrentChanged(cur_idx, prev_idx) {
if (prev_idx.valid && storeContentY) {
let key = prefix + theSessionData.get(prev_idx, "idRole")
scrollKeeper[key] = storeContentY
storeContentY = 0
}

let key = prefix + inspectedMediaSetProperties.values.idRole
if (typeof scrollKeeper == "object" && scrollKeeper.hasOwnProperty(key)) {
contentY = scrollKeeper[key]
}
}
}

// machanisms to store and restore the scroll position
// whenever the mode is changed between grid and list
Component.onDestruction: {
let id_ = inspectedMediaSetProperties.values.idRole
if (id_ && typeof scrollKeeper == "object" ) {
let key = prefix + id_
scrollKeeper[key] = contentY
}
}
Component.onCompleted: {
let id_ = inspectedMediaSetProperties.values.idRole
if (id_) {
let key = prefix + id_
if (typeof scrollKeeper == "object" && scrollKeeper.hasOwnProperty(key))
contentY = scrollKeeper[key]
}
}
}
1 change: 1 addition & 0 deletions ui/qml/xstudio/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<file>application/panels/media/widgets/XsMediaListContextMenu.qml</file>
<file>application/panels/media/widgets/XsMediaListSwitchSourceMenu.qml</file>
<file>application/panels/media/widgets/XsMediaHotKeys.qml</file>
<file>application/panels/media/widgets/XsMediaScrollKeeper.qml</file>
<file>application/panels/media/delegates/XsMediaThumbnailHighlight.qml</file>
<file>application/panels/media/delegates/XsMediaThumbnailImage.qml</file>

Expand Down
Loading