@ -90,7 +90,7 @@ const filePathToUrl = window.require('file-url');
const { parse : parsePath , join : pathJoin , basename , dirname } = window . require ( 'path' ) ;
const remote = window . require ( '@electron/remote' ) ;
const { focusWindow , hasDisabledNetworking } = remote . require ( './electron' ) ;
const { focusWindow , hasDisabledNetworking , quitApp } = remote . require ( './electron' ) ;
const calcShouldShowWaveform = ( zoomedDuration ) => ( zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8 ) ;
@ -1890,7 +1890,7 @@ const App = memo(() => {
electron . clipboard . writeText ( await formatTsv ( selectedSegments ) ) ;
} , [ isFileOpened , selectedSegments ] ) ;
const onKeyPress = useCallback ( ( { action , keyup } ) => {
const getKeyboardAction = useCallback ( ( { action , keyup } ) => {
function seekReset ( ) {
seekAccelerationRef . current = 1 ;
}
@ -1996,10 +1996,15 @@ const App = memo(() => {
decreaseVolume : ( ) => setPlaybackVolume ( ( val ) => Math . max ( 0 , val - 0.07 ) ) ,
copySegmentsToClipboard ,
reloadFile : ( ) => setCacheBuster ( ( v ) => v + 1 ) ,
quit : ( ) => quitApp ( ) ,
} ;
return mainActions [ action ] ;
} , [ addSegment , alignSegmentTimesToKeyframes , askSetStartTimeOffset , batchFileJump , batchOpenSelectedFile , captureSnapshot , captureSnapshotAsCoverArt , changePlaybackRate , cleanupFilesDialog , clearSegments , closeBatch , combineOverlappingSegments , combineSelectedSegments , concatCurrentBatch , convertFormatBatch , copySegmentsToClipboard , createFixedDurationSegments , createNumSegments , createRandomSegments , currentSegIndexSafe , cutSegmentsHistory , deselectAllSegments , duplicateCurrentSegment , extractAllStreams , extractCurrentSegmentFramesAsImages , extractSelectedSegmentsFramesAsImages , fillSegmentsGaps , goToTimecode , increaseRotation , invertAllSegments , invertSelectedSegments , jumpCutEnd , jumpCutStart , jumpSeg , jumpTimelineEnd , jumpTimelineStart , keyboardNormalSeekSpeed , keyboardSeekAccFactor , onExportPress , onLabelSegment , pause , play , removeCutSegment , removeSelectedSegments , reorderSegsByStartTime , seekClosestKeyframe , seekRel , seekRelPercent , selectAllSegments , selectOnlyCurrentSegment , setCutEnd , setCutStart , setPlaybackVolume , shiftAllSegmentTimes , shortStep , shuffleSegments , splitCurrentSegment , timelineToggleComfortZoom , toggleCaptureFormat , toggleCurrentSegmentSelected , toggleKeyframeCut , toggleLastCommands , toggleLoopSelectedSegments , togglePlay , toggleSegmentsList , toggleStreamsSelector , toggleStripAudio , tryFixInvalidDuration , userHtml5ifyCurrentFile , zoomRel ] ) ;
const onKeyPress = useCallback ( ( { action , keyup } ) => {
function tryMainActions ( ) {
const fn = mainActions [ action ] ;
const fn = getKeyboardAction( { action , keyup } ) ;
if ( ! fn ) return { match : false } ;
const bubble = fn ( ) ;
return { match : true , bubble } ;
@ -2038,7 +2043,7 @@ const App = memo(() => {
if ( match ) return bubble ;
return true ; / / b u b b l e t h e e v e n t
} , [ addSegment, alignSegmentTimesToKeyframes , askSetStartTimeOffset , batchFileJump , batchOpenSelectedFile , captureSnapshot , captureSnapshotAsCoverArt , changePlaybackRate , cleanupFilesDialog , clearSegments , closeBatch , closeExportConfirm , combineOverlappingSegments , combineSelectedSegments , concatCurrentBatch , concatDialogVisible , convertFormatBatch , copySegmentsToClipboard , createFixedDurationSegments , createNumSegments , createRandomSegments , currentSegIndexSafe , cutSegmentsHistory , deselectAllSegments , duplicateCurrentSegment , exportConfirmVisible , extractAllStreams , extractCurrentSegmentFramesAsImages , extractSelectedSegmentsFramesAsImages , fillSegmentsGaps , goToTimecode , increaseRotation , invertAllSegments , invertSelectedSegments , jumpCutEnd , jumpCutStart , jumpSeg , jumpTimelineEnd , jumpTimelineStart , keyboardNormalSeekSpeed , keyboardSeekAccFactor , keyboardShortcutsVisible , onExportConfirm , onExportPress, onLabelSegment , pause , play , removeCutSegment , removeSelectedSegments , reorderSegsByStartTime , seekClosestKeyframe , seekRel , seekRelPercent , selectAllSegments , selectOnlyCurrentSegment , setCutEnd , setCutStart , setPlaybackVolume , shiftAllSegmentTimes , shortStep , shuffleSegments , splitCurrentSegment , timelineToggleComfortZoom , toggleCaptureFormat , toggleCurrentSegmentSelected , toggleKeyboardShortcuts, toggleKeyframeCut , toggleLastCommands , toggleLoopSelectedSegments , togglePlay , toggleSegmentsList , toggleStreamsSelector , toggleStripAudio , tryFixInvalidDuration , userHtml5ifyCurrentFile , zoomRel ] ) ;
} , [ closeExportConfirm, concatDialogVisible , exportConfirmVisible , getKeyboardAction , keyboardShortcutsVisible , onExportConfirm , toggleKeyboardShortcuts] ) ;
useKeyboard ( { keyBindings , onKeyPress } ) ;
@ -2148,8 +2153,18 @@ const App = memo(() => {
}
}
function tryKeyboardAction ( action ) {
const fn = getKeyboardAction ( { action } ) ;
if ( ! fn ) {
console . error ( 'Action not found:' , action ) ;
return ;
}
fn ( ) ;
}
const actions = {
openFiles : ( event , filePaths ) => { userOpenFiles ( filePaths . map ( resolvePathIfNeeded ) ) ; } ,
apiKeyboardAction : ( event , action ) => tryKeyboardAction ( action ) ,
openFilesDialog ,
closeCurrentFile : ( ) => { closeFileWithConfirm ( ) ; } ,
closeBatchFiles : ( ) => { closeBatch ( ) ; } ,
@ -2197,7 +2212,7 @@ const App = memo(() => {
actionsWithCatch . forEach ( ( [ key , action ] ) => electron . ipcRenderer . on ( key , action ) ) ;
return ( ) => actionsWithCatch . forEach ( ( [ key , action ] ) => electron . ipcRenderer . removeListener ( key , action ) ) ;
} , [ alignSegmentTimesToKeyframes , apparentCutSegments , askSetStartTimeOffset , checkFileOpened , clearSegments , closeBatch , closeFileWithConfirm , combineOverlappingSegments , combineSelectedSegments , concatCurrentBatch , createFixedDurationSegments , createNumSegments , createRandomSegments , createSegmentsFromKeyframes , customOutDir , cutSegments , detectBlackScenes , detectSceneChanges , detectSilentScenes , detectedFps , extractAllStreams , fileFormat , filePath , fillSegmentsGaps , getFrameCount , handleShowStreamsSelectorClick, invertAllSegments , loadCutSegments , loadMedia , openFilesDialog , openSendReportDialogWithState , reorderSegsByStartTime , selectedSegments , setWorking , shiftAllSegmentTimes , shuffleSegments , toggleKeyboardShortcuts , toggleLastCommands , toggleSettings , tryFixInvalidDuration , userHtml5ifyCurrentFile , userOpenFiles ] ) ;
} , [ alignSegmentTimesToKeyframes , apparentCutSegments , askSetStartTimeOffset , checkFileOpened , clearSegments , closeBatch , closeFileWithConfirm , combineOverlappingSegments , combineSelectedSegments , concatCurrentBatch , createFixedDurationSegments , createNumSegments , createRandomSegments , createSegmentsFromKeyframes , customOutDir , cutSegments , detectBlackScenes , detectSceneChanges , detectSilentScenes , detectedFps , extractAllStreams , fileFormat , filePath , fillSegmentsGaps , getFrameCount , getKeyboardAction, handleShowStreamsSelectorClick, invertAllSegments , loadCutSegments , loadMedia , openFilesDialog , openSendReportDialogWithState , reorderSegsByStartTime , selectedSegments , setWorking , shiftAllSegmentTimes , shuffleSegments , toggleKeyboardShortcuts , toggleLastCommands , toggleSettings , tryFixInvalidDuration , userHtml5ifyCurrentFile , userOpenFiles ] ) ;
const showAddStreamSourceDialog = useCallback ( async ( ) => {
try {