diff --git a/krita/krita.action b/krita/krita.action
index 4456b6c7b1..91af65a0fc 100644
--- a/krita/krita.action
+++ b/krita/krita.action
@@ -1,3597 +1,3598 @@
General
Open Resources Folder
Opens a file browser at the location Krita saves resources such as brushes to.
Opens a file browser at the location Krita saves resources such as brushes to.
Open Resources Folder
0
0
false
C&ascade
Cascade
Cascade
10
0
false
&Tile
Tile
Tile
10
0
false
Create Resource Bundle...
Create Resource Bundle
Create Resource Bundle
0
0
false
Show File Toolbar
Show File Toolbar
Show File Toolbar
false
Show color selector
Show color selector
Show color selector
Shift+I
false
Show MyPaint shade selector
Show MyPaint shade selector
Show MyPaint shade selector
Shift+M
false
Show minimal shade selector
Show minimal shade selector
Show minimal shade selector
Shift+N
false
Show color history
Show color history
Show color history
H
false
Show common colors
Show common colors
Show common colors
U
false
Show Tool Options
Show Tool Options
Show Tool Options
\
false
Show Brush Editor
Show Brush Editor
Show Brush Editor
F5
false
Show Brush Presets
Show Brush Presets
Show Brush Presets
F6
false
Toggle Tablet Debugger
Toggle Tablet Debugger
Toggle Tablet Debugger
0
0
Ctrl+Shift+T
false
Show Krita log for bug reports.
Show Krita log for bug reports.
Show Krita log for bug reports.
false
Show system information for bug reports.
Show system information for bug reports.
Show system information for bug reports.
false
Rename Composition...
Rename Composition
Rename Composition
0
0
false
Update Composition
Update Composition
Update Composition
0
0
false
Use multiple of 2 for pixel scale
Use multiple of 2 for pixel scale
Use multiple of 2 for pixel scale
Use multiple of 2 for pixel scale
1
0
true
&Invert Selection
Invert current selection
Invert Selection
10000000000
100
Ctrl+Shift+I
false
Create Snapshot
Create Snapshot
1
0
false
Switch to Selected Snapshot
Switch to selected snapshot
1
0
false
Remove Selected Snapshot
Remove Selected Snapshot
1
0
false
Painting
lightness-increase
Make brush color lighter
Make brush color lighter
Make brush color lighter
0
0
L
false
lightness-decrease
Make brush color darker
Make brush color darker
Make brush color darker
0
0
K
false
Make brush color more saturated
Make brush color more saturated
Make brush color more saturated
false
Make brush color more desaturated
Make brush color more desaturated
Make brush color more desaturated
false
Shift brush color hue clockwise
Shift brush color hue clockwise
Shift brush color hue clockwise
false
Shift brush color hue counter-clockwise
Shift brush color hue counter-clockwise
Shift brush color hue counter-clockwise
false
Make brush color more red
Make brush color more red
Make brush color more red
false
Make brush color more green
Make brush color more green
Make brush color more green
false
Make brush color more blue
Make brush color more blue
Make brush color more blue
false
Make brush color more yellow
Make brush color more yellow
Make brush color more yellow
false
opacity-increase
Increase opacity
Increase opacity
Increase opacity
0
0
O
false
opacity-decrease
Decrease opacity
Decrease opacity
Decrease opacity
0
0
I
false
draw-eraser
Set eraser mode
Set eraser mode
Set eraser mode
10000
0
E
true
view-refresh
Reload Original Preset
Reload Original Preset
Reload Original Preset
10000
false
transparency-unlocked
Preserve Alpha
Preserve Alpha
Preserve Alpha
10000
true
transform_icons_penPressure
Use Pen Pressure
Use Pen Pressure
Use Pen Pressure
10000
true
symmetry-horizontal
Horizontal Mirror Tool
Horizontal Mirror Tool
Horizontal Mirror Tool
0
true
symmetry-vertical
Vertical Mirror Tool
Vertical Mirror Tool
Vertical Mirror Tool
0
true
Hide Mirror X Line
Hide Mirror X Line
Hide Mirror X Line
10000
true
Hide Mirror Y Line
Hide Mirror Y Line
Hide Mirror Y Line
10000
true
Lock
Lock X Line
Lock X Line
10000
true
Lock Y Line
Lock Y Line
Lock Y Line
10000
true
Move to Canvas Center X
Move to Canvas Center X
Move to Canvas Center X
10000
false
Move to Canvas Center Y
Move to Canvas Center Y
Move to Canvas Center Y
10000
false
&Toggle Selection Display Mode
Toggle Selection Display Mode
Toggle Selection Display Mode
0
0
false
Next Favourite Preset
Next Favourite Preset
Next Favourite Preset
,
false
Previous Favourite Preset
Previous Favourite Preset
Previous Favourite Preset
.
false
preset-switcher
Switch to Previous Preset
Switch to Previous Preset
Switch to Previous Preset
/
false
Hide Brushes and Stuff Toolbar
Hide Brushes and Stuff Toolbar
Hide Brushes and Stuff Toolbar
true
Reset Foreground and Background Color
Reset Foreground and Background Color
Reset Foreground and Background Color
D
false
Swap Foreground and Background Color
Swap Foreground and Background Color
Swap Foreground and Background Color
X
false
Selection Mode: Add
Selection Mode: Add
Selection Mode: Add
A
false
Selection Mode: Subtract
Selection Mode: Subtract
Selection Mode: Subtract
S
false
Selection Mode: Intersect
Selection Mode: Intersect
Selection Mode: Intersect
false
Selection Mode: Replace
Selection Mode: Replace
Selection Mode: Replace
R
false
smoothing-weighted
Brush Smoothing: Weighted
Brush Smoothing: Weighted
Brush Smoothing: Weighted
false
smoothing-no
Brush Smoothing: Disabled
Brush Smoothing: Disabled
Brush Smoothing: Disabled
false
smoothing-stabilizer
Brush Smoothing: Stabilizer
Brush Smoothing: Stabilizer
Brush Smoothing: Stabilizer
false
brushsize-decrease
Decrease Brush Size
Decrease Brush Size
Decrease Brush Size
0
0
[
false
smoothing-basic
Brush Smoothing: Basic
Brush Smoothing: Basic
Brush Smoothing: Basic
false
brushsize-increase
Increase Brush Size
Increase Brush Size
Increase Brush Size
0
0
]
false
Toggle Snap To Assistants
Toggle Snap to Assistants
ToggleAssistant
Ctrl+Shift+L
true
Undo Polygon Selection Points
Undo Polygon Selection Points
Undo Polygon Selection Points
Shift+Z
false
Fill with Foreground Color (Opacity)
Fill with Foreground Color (Opacity)
Fill with Foreground Color (Opacity)
10000
1
Ctrl+Shift+Backspace
false
Fill with Background Color (Opacity)
Fill with Background Color (Opacity)
Fill with Background Color (Opacity)
10000
1
Ctrl+Backspace
false
Fill with Pattern (Opacity)
Fill with Pattern (Opacity)
Fill with Pattern (Opacity)
10000
1
false
Convert &to Shape
Convert to Shape
Convert to Shape
10000000000
0
false
&Show Global Selection Mask
Shows global selection as a usual selection mask in <interface>Layers</interface> docker
Show Global Selection Mask
100000
100
true
Filters
color-to-alpha
&Color to Alpha...
Color to Alpha
Color to Alpha
10000
0
false
&Top Edge Detection
Top Edge Detection
Top Edge Detection
10000
0
false
&Index Colors...
Index Colors
Index Colors
10000
0
false
Emboss Horizontal &Only
Emboss Horizontal Only
Emboss Horizontal Only
10000
0
false
D&odge
Dodge
Dodge
10000
0
false
&Sharpen
Sharpen
Sharpen
10000
0
false
B&urn
Burn
Burn
10000
0
false
&Mean Removal
Mean Removal
Mean Removal
10000
0
false
&Gaussian Blur...
Gaussian Blur
Gaussian Blur
10000
0
false
Emboss &in All Directions
Emboss in All Directions
Emboss in All Directions
10000
0
false
&Small Tiles...
Small Tiles
Small Tiles
10000
0
false
&Levels...
Levels
Levels
10000
0
Ctrl+L
false
&Sobel...
Sobel
Sobel
10000
0
false
&Wave...
Wave
Wave
10000
0
false
&Motion Blur...
Motion Blur
Motion Blur
10000
0
false
&Invert
Invert
Invert
10000
0
Ctrl+I
false
&Color Adjustment curves...
Color Adjustment curves
Color Adjustment curves
10000
0
Ctrl+M
false
Pi&xelize...
Pixelize
Pixelize
10000
0
false
Emboss (&Laplacian)
Emboss (Laplacian)
Emboss (Laplacian)
10000
0
false
&Left Edge Detection
Left Edge Detection
Left Edge Detection
10000
0
false
&Blur...
Blur
Blur
10000
0
false
&Raindrops...
Raindrops
Raindrops
10000
0
false
&Bottom Edge Detection
Bottom Edge Detection
Bottom Edge Detection
10000
0
false
&Random Noise...
Random Noise
Random Noise
10000
0
false
&Brightness/Contrast curve...
Brightness/Contrast curve
Brightness/Contrast curve
10000
0
false
Colo&r Balance...
Color Balance
Color Balance
10000
0
Ctrl+B
false
&Phong Bumpmap...
Phong Bumpmap
Phong Bumpmap
10000
0
false
&Desaturate
Desaturate
Desaturate
10000
0
Ctrl+Shift+U
false
Color &Transfer...
Color Transfer
Color Transfer
10000
0
false
Emboss &Vertical Only
Emboss Vertical Only
Emboss Vertical Only
10000
0
false
&Lens Blur...
Lens Blur
Lens Blur
10000
0
false
M&inimize Channel
Minimize Channel
Minimize Channel
10000
0
false
M&aximize Channel
Maximize Channel
Maximize Channel
10000
0
false
&Oilpaint...
Oilpaint
Oilpaint
10000
0
false
&Right Edge Detection
Right Edge Detection
Right Edge Detection
10000
0
false
&Auto Contrast
Auto Contrast
Auto Contrast
10000
0
false
&Round Corners...
Round Corners
Round Corners
10000
0
false
&Unsharp Mask...
Unsharp Mask
Unsharp Mask
10000
0
false
&Emboss with Variable Depth...
Emboss with Variable Depth
Emboss with Variable Depth
10000
0
false
Emboss &Horizontal && Vertical
Emboss Horizontal & Vertical
Emboss Horizontal & Vertical
10000
0
false
Random &Pick...
Random Pick
Random Pick
10000
0
false
&Gaussian Noise Reduction...
Gaussian Noise Reduction
Gaussian Noise Reduction
10000
0
false
&Posterize...
Posterize
Posterize
10000
0
false
&Wavelet Noise Reducer...
Wavelet Noise Reducer
Wavelet Noise Reducer
10000
0
false
&HSV Adjustment...
HSV Adjustment
HSV Adjustment
10000
0
Ctrl+U
false
Tool Shortcuts
Dynamic Brush Tool
Dynamic Brush Tool
Dynamic Brush Tool
false
Rectangle Tool
Rectangle Tool
Rectangle Tool
false
Multibrush Tool
Multibrush Tool
Multibrush Tool
Q
false
Colorize Mask Tool
Colorize Mask Tool
Colorize Mask Tool
Smart Patch Tool
Smart Patch Tool
Smart Patch Tool
Pan Tool
Pan Tool
Pan Tool
Select Shapes Tool
Select Shapes Tool
Select Shapes Tool
false
Color Picker
Select a color from the image or current layer
Select a color from the image or current layer
P
false
Outline Selection Tool
Outline Selection Tool
Outline Selection Tool
false
Fill Tool
Fill a contiguous area of color with a color, or fill a selection.
Fill a contiguous area of color with a color, or fill a selection.
F
false
Line Tool
Line Tool
Line Tool
false
Ellipse Tool
Ellipse Tool
Ellipse Tool
false
Freehand Brush Tool
Freehand Brush Tool
Freehand Brush Tool
B
false
Create object
Create object
Create object
false
Pattern editing
Pattern editing
Pattern editing
false
Review
Review
Review
false
Draw a gradient.
Draw a gradient.
Draw a gradient.
G
false
Measurement Tool
Measure the distance between two points
Measure the distance between two points
false
Move Tool
Move a layer
Move a layer
T
false
Vector Image Tool
Vector Image (EMF/WMF/SVM/SVG) tool
Vector Image (EMF/WMF/SVM/SVG) tool
false
Calligraphy
Calligraphy
Calligraphy
false
Edit Shapes Tool
Edit Shapes Tool
Edit Shapes Tool
false
Zoom Tool
Zoom Tool
Zoom Tool
false
Assistant Tool
Assistant Tool
Assistant Tool
false
Gradient Editing Tool
Gradient editing
Gradient editing
false
Reference Images Tool
Reference Images Tool
Reference Images Tool
false
Blending Modes
Select Normal Blending Mode
Select Normal Blending Mode
Select Normal Blending Mode
0
0
Alt+Shift+N
false
Select Dissolve Blending Mode
Select Dissolve Blending Mode
Select Dissolve Blending Mode
0
0
Alt+Shift+I
false
Select Behind Blending Mode
Select Behind Blending Mode
Select Behind Blending Mode
0
0
Alt+Shift+Q
false
Select Clear Blending Mode
Select Clear Blending Mode
Select Clear Blending Mode
0
0
Alt+Shift+R
false
Select Darken Blending Mode
Select Darken Blending Mode
Select Darken Blending Mode
0
0
Alt+Shift+K
false
Select Multiply Blending Mode
Select Multiply Blending Mode
Select Multiply Blending Mode
0
0
Alt+Shift+M
false
Select Color Burn Blending Mode
Select Color Burn Blending Mode
Select Color Burn Blending Mode
0
0
Alt+Shift+B
false
Select Linear Burn Blending Mode
Select Linear Burn Blending Mode
Select Linear Burn Blending Mode
0
0
Alt+Shift+A
false
Select Lighten Blending Mode
Select Lighten Blending Mode
Select Lighten Blending Mode
0
0
Alt+Shift+G
false
Select Screen Blending Mode
Select Screen Blending Mode
Select Screen Blending Mode
0
0
Alt+Shift+S
false
Select Color Dodge Blending Mode
Select Color Dodge Blending Mode
Select Color Dodge Blending Mode
0
0
Alt+Shift+D
false
Select Linear Dodge Blending Mode
Select Linear Dodge Blending Mode
Select Linear Dodge Blending Mode
0
0
Alt+Shift+W
false
Select Overlay Blending Mode
Select Overlay Blending Mode
Select Overlay Blending Mode
0
0
Alt+Shift+O
false
Select Hard Overlay Blending Mode
Select Hard Overlay Blending Mode
Select Hard Overlay Blending Mode
0
0
Alt+Shift+P
false
Select Soft Light Blending Mode
Select Soft Light Blending Mode
Select Soft Light Blending Mode
0
0
Alt+Shift+F
false
Select Hard Light Blending Mode
Select Hard Light Blending Mode
Select Hard Light Blending Mode
0
0
Alt+Shift+H
false
Select Vivid Light Blending Mode
Select Vivid Light Blending Mode
Select Vivid Light Blending Mode
0
0
Alt+Shift+V
false
Select Linear Light Blending Mode
Select Linear Light Blending Mode
Select Linear Light Blending Mode
0
0
Alt+Shift+J
false
Select Pin Light Blending Mode
Select Pin Light Blending Mode
Select Pin Light Blending Mode
0
0
Alt+Shift+Z
false
Select Hard Mix Blending Mode
Select Hard Mix Blending Mode
Select Hard Mix Blending Mode
0
0
Alt+Shift+L
false
Select Difference Blending Mode
Select Difference Blending Mode
Select Difference Blending Mode
0
0
Alt+Shift+E
false
Select Exclusion Blending Mode
Select Exclusion Blending Mode
Select Exclusion Blending Mode
0
0
Alt+Shift+X
false
Select Hue Blending Mode
Select Hue Blending Mode
Select Hue Blending Mode
0
0
Alt+Shift+U
false
Select Saturation Blending Mode
Select Saturation Blending Mode
Select Saturation Blending Mode
0
0
Alt+Shift+T
false
Select Color Blending Mode
Select Color Blending Mode
Select Color Blending Mode
0
0
Alt+Shift+C
false
Select Luminosity Blending Mode
Select Luminosity Blending Mode
Select Luminosity Blending Mode
0
0
Alt+Shift+Y
false
Animation
prevframe
Previous frame
Move to previous frame
Move to previous frame
1
0
false
nextframe
Next frame
Move to next frame
Move to next frame
1
0
false
animation_play
Play / pause animation
Play / pause animation
Play / pause animation
1
0
false
animation_stop
Stop animation
Stop animation
Stop animation
1
0
false
addblankframe
Create Blank Frame
Add blank frame
Add blank frame
100000
0
false
addduplicateframe
Create Duplicate Frame
Add duplicate frame
Add duplicate frame
100000
0
false
Toggle onion skin
Toggle onion skin
Toggle onion skin
100000
0
false
Previous Keyframe
false
Next Keyframe
false
First Frame
false
Last Frame
false
Auto Frame Mode
true
-
-
+ dropframe
+ Drop Frames
+Enable to preserve playback timing.
true
Pin to Timeline
If checked, layer becomes pinned to the timeline, making it visible even when inactive.
true
Insert Keyframe Left
Insert keyframes to the left of selection, moving the tail of animation to the right.
100000
0
false
Insert Keyframe Right
Insert keyframes to the right of selection, moving the tail of animation to the right.
100000
0
false
Insert Multiple Keyframes
Insert several keyframes based on user parameters.
100000
0
false
Remove Frame and Pull
Remove keyframes moving the tail of animation to the left
100000
0
false
deletekeyframe
Remove Keyframe
Remove keyframes without moving anything around
100000
0
false
Insert Column Left
Insert column to the left of selection, moving the tail of animation to the right
100000
0
false
Insert Column Right
Insert column to the right of selection, moving the tail of animation to the right
100000
0
false
Insert Multiple Columns
Insert several columns based on user parameters.
100000
0
false
Remove Column and Pull
Remove columns moving the tail of animation to the left
100000
0
false
Remove Column
Remove columns without moving anything around
100000
0
false
Insert Hold Frame
Insert a hold frame after every keyframe
100000
0
false
Insert Multiple Hold Frames
Insert N hold frames after every keyframe
100000
0
false
Remove Hold Frame
Remove a hold frame after every keyframe
100000
0
false
Remove Multiple Hold Frames
Remove N hold frames after every keyframe
100000
0
false
Insert Hold Column
Insert a hold column into the frame at the current position
100000
0
false
Insert Multiple Hold Columns
Insert N hold columns into the frame at the current position
100000
0
false
Remove Hold Column
Remove a hold column from the frame at the current position
100000
0
false
Remove Multiple Hold Columns
Remove N hold columns from the frame at the current position
100000
0
false
Add opacity keyframe
Adds keyframe to control layer opacity
100000
0
false
Remove opacity keyframe
Removes keyframe to control layer opacity
100000
0
false
Mirror Frames
Mirror frames' position
100000
0
false
Mirror Columns
Mirror columns' position
100000
0
false
Copy to Clipboard
Copy frames to clipboard
100000
0
false
Cut to Clipboard
Cut frames to clipboard
100000
0
false
Paste from Clipboard
Paste frames from clipboard
100000
0
false
Copy Columns to Clipboard
Copy columns to clipboard
100000
0
false
Cut Columns to Clipboard
Cut columns to clipboard
100000
0
false
Paste Columns from Clipboard
Paste columns from clipboard
100000
0
false
Set Start Time
100000
0
false
Set End Time
100000
0
false
Update Playback Range
100000
0
false
Layers
Activate next layer
Activate next layer
Activate next layer
1000
0
PgUp
false
Activate next sibling layer, skipping over groups.
Activate next sibling layer
Activate next sibling layer
1000
0
false
Activate previous layer
Activate previous layer
Activate previous layer
1000
0
PgDown
false
Activate previous sibling layer, skipping over groups.
Activate previous sibling layer
Activate previous sibling layer
1000
0
false
Activate previously selected layer
Activate previously selected layer
Activate previously selected layer
1000
0
;
false
groupLayer
&Group Layer
Group Layer
Group Layer
1000
0
false
cloneLayer
&Clone Layer
Clone Layer
Clone Layer
1000
0
false
vectorLayer
&Vector Layer
Vector Layer
Vector Layer
1000
0
false
filterLayer
&Filter Layer...
Filter Layer
Filter Layer
1000
0
false
fillLayer
&Fill Layer...
Fill Layer
Fill Layer
1000
0
false
fileLayer
&File Layer...
File Layer
File Layer
1000
0
false
transparencyMask
&Transparency Mask
Transparency Mask
Transparency Mask
100000
0
false
filterMask
&Filter Mask...
Filter Mask
Filter Mask
100000
0
false
filterMask
&Colorize Mask
Colorize Mask
Colorize Mask
100000
0
false
transformMask
&Transform Mask...
Transform Mask
Transform Mask
100000
0
false
selectionMask
&Local Selection
Local Selection
Local Selection
100000
0
false
view-filter
&Isolate Active Layer
Isolate Active Layer
Isolate Active Layer
1000
0
true
layer-locked
&Toggle layer lock
Toggle layer lock
Toggle layer lock
1000
0
false
visible
Toggle layer &visibility
Toggle layer visibility
Toggle layer visibility
1000
0
false
transparency-locked
Toggle layer &alpha
Toggle layer alpha
Toggle layer alpha
1000
0
false
transparency-enabled
Toggle layer alpha &inheritance
Toggle layer alpha inheritance
Toggle layer alpha inheritance
1000
0
false
paintLayer
&Paint Layer
Paint Layer
Paint Layer
1000
0
Insert
false
&New Layer From Visible
New layer from visible
New layer from visible
1000
0
false
duplicatelayer
&Duplicate Layer or Mask
Duplicate Layer or Mask
Duplicate Layer or Mask
1000
0
Ctrl+J
false
&Cut Selection to New Layer
Cut Selection to New Layer
Cut Selection to New Layer
100000000
1
Ctrl+Shift+J
false
Copy &Selection to New Layer
Copy Selection to New Layer
Copy Selection to New Layer
100000000
0
Ctrl+Alt+J
false
Copy Layer
Copy layer to clipboard
Copy layer to clipboard
1000
0
false
Cut Layer
Cut layer to clipboard
Cut layer to clipboard
1000
0
false
Paste Layer
Paste layer from clipboard
Paste layer from clipboard
1000
0
false
Quick Group
Create a group layer containing selected layers
Quick Group
1000
0
Ctrl+G
false
Quick Ungroup
Remove grouping of the layers or remove one layer out of the group
Quick Ungroup
100000
0
Ctrl+Alt+G
false
Quick Clipping Group
Group selected layers and add a layer with clipped alpha channel
Quick Clipping Group
100000
0
Ctrl+Shift+G
false
All Layers
Select all layers
Select all layers
10000
0
false
Visible Layers
Select all visible layers
Select all visible layers
10000
0
false
Locked Layers
Select all locked layers
Select all locked layers
10000
0
false
Invisible Layers
Select all invisible layers
Select all invisible layers
10000
0
false
Unlocked Layers
Select all unlocked layers
Select all unlocked layers
10000
0
false
document-save
&Save Layer/Mask...
Save Layer/Mask
Save Layer/Mask
1000
0
false
document-save
Save Vector Layer as SVG...
Save Vector Layer as SVG
Save Vector Layer as SVG
1000
0
false
document-save
Save &Group Layers...
Save Group Layers
Save Group Layers
100000
0
false
Convert group to &animated layer
Convert child layers into animation frames
Convert child layers into animation frames
100000
0
false
Convert to &animated layer
Convert layer into animation frames
Convert layer into animation frames
100000
0
false
fileLayer
to &File Layer
Saves out the layers into a new image and then references that image.
Convert to File Layer
100000
0
false
I&mport Layer...
Import Layer
Import Layer
100000
0
false
paintLayer
&as Paint Layer...
as Paint Layer
as Paint Layer
1000
0
false
transparencyMask
as &Transparency Mask...
as Transparency Mask
as Transparency Mask
1000
0
false
filterMask
as &Filter Mask...
as Filter Mask
as Filter Mask
1000
0
false
selectionMask
as &Selection Mask...
as Selection Mask
as Selection Mask
1000
0
false
paintLayer
to &Paint Layer
to Paint Layer
to Paint Layer
1000
0
false
transparencyMask
to &Transparency Mask
to Transparency Mask
to Transparency Mask
1000
0
false
filterMask
to &Filter Mask...
to Filter Mask
to Filter Mask
1000
0
false
selectionMask
to &Selection Mask
to Selection Mask
to Selection Mask
1000
0
false
transparencyMask
&Alpha into Mask
Alpha into Mask
Alpha into Mask
100000
10
false
transparency-enabled
&Write as Alpha
Write as Alpha
Write as Alpha
1000000
1
false
document-save
&Save Merged...
Save Merged
Save Merged
1000000
0
false
split-layer
Split Layer...
Split Layer
Split Layer
1000
0
false
Wavelet Decompose ...
Wavelet Decompose
Wavelet Decompose
1000
1
false
symmetry-horizontal
Mirror Layer Hori&zontally
Mirror Layer Horizontally
Mirror Layer Horizontally
1000
1
false
symmetry-vertical
Mirror Layer &Vertically
Mirror Layer Vertically
Mirror Layer Vertically
1000
1
false
&Rotate Layer...
Rotate Layer
Rotate Layer
1000
1
false
object-rotate-right
Rotate &Layer 90° to the Right
Rotate Layer 90° to the Right
Rotate Layer 90° to the Right
1000
1
false
object-rotate-left
Rotate Layer &90° to the Left
Rotate Layer 90° to the Left
Rotate Layer 90° to the Left
1000
1
false
Rotate Layer &180°
Rotate Layer 180°
Rotate Layer 180°
1000
1
false
Scale &Layer to new Size...
Scale Layer to new Size
Scale Layer to new Size
100000
1
false
&Shear Layer...
Shear Layer
Shear Layer
1000
1
false
symmetry-horizontal
Mirror All Layers Hori&zontally
Mirror All Layers Horizontally
Mirror All Layers Horizontally
1000
1
false
symmetry-vertical
Mirror All Layers &Vertically
Mirror All Layers Vertically
Mirror All Layers Vertically
1000
1
false
&Rotate All Layers...
Rotate All Layers
Rotate All Layers
1000
1
false
object-rotate-right
Rotate All &Layers 90° to the Right
Rotate All Layers 90° to the Right
Rotate All Layers 90° to the Right
1000
1
false
object-rotate-left
Rotate All Layers &90° to the Left
Rotate All Layers 90° to the Left
Rotate All Layers 90° to the Left
1000
1
false
Rotate All Layers &180°
Rotate All Layers 180°
Rotate All Layers 180°
1000
1
false
Scale All &Layers to new Size...
Scale All Layers to new Size
Scale All Layers to new Size
100000
1
false
&Shear All Layers...
Shear All Layers
Shear All Layers
1000
1
false
&Offset Layer...
Offset Layer
Offset Layer
100000
1
false
Clones &Array...
Clones Array
Clones Array
100000
0
false
&Edit metadata...
Edit metadata
Edit metadata
100000
1
false
&Histogram...
Histogram
Histogram
100000
0
false
&Convert Layer Color Space...
Convert Layer Color Space
Convert Layer Color Space
100000
1
false
merge-layer-below
&Merge with Layer Below
Merge with Layer Below
Merge with Layer Below
100000
0
Ctrl+E
false
&Flatten Layer
Flatten Layer
Flatten Layer
100000
0
false
Ras&terize Layer
Rasterize Layer
Rasterize Layer
10000000
1
false
Flatten ima&ge
Flatten image
Flatten image
100000
0
Ctrl+Shift+E
false
La&yer Style...
Layer Style
Layer Style
100000
1
false
Move into previous group
Move into previous group
Move into previous group
0
0
false
Move into next group
Move into next group
Move into next group
0
0
false
Rename current layer
Rename current layer
Rename current layer
100000
0
F2
false
deletelayer
&Remove Layer
Remove Layer
Remove Layer
1000
1
Shift+Delete
false
arrowupblr
Move Layer or Mask Up
Move Layer or Mask Up
Ctrl+PgUp
false
arrowdown
Move Layer or Mask Down
Move Layer or Mask Down
Ctrl+PgDown
false
properties
&Properties...
Properties
Properties
1000
1
F3
false
Set Copy F&rom...
Set the source for the selected clone layer(s).
Set Copy From
1000
1
false
diff --git a/libs/image/kis_image_animation_interface.cpp b/libs/image/kis_image_animation_interface.cpp
index 2edb94d12e..d2d5e8614c 100644
--- a/libs/image/kis_image_animation_interface.cpp
+++ b/libs/image/kis_image_animation_interface.cpp
@@ -1,426 +1,428 @@
/*
* Copyright (c) 2015 Dmitry Kazakov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_image_animation_interface.h"
#include
#include "kis_global.h"
#include "kis_image.h"
#include "kis_regenerate_frame_stroke_strategy.h"
#include "kis_switch_time_stroke_strategy.h"
#include "kis_keyframe_channel.h"
#include "kis_time_range.h"
#include "kis_post_execution_undo_adapter.h"
#include "commands_new/kis_switch_current_time_command.h"
#include "kis_layer_utils.h"
struct KisImageAnimationInterface::Private
{
Private()
: image(0),
externalFrameActive(false),
frameInvalidationBlocked(false),
cachedLastFrameValue(-1),
audioChannelMuted(false),
audioChannelVolume(0.5),
m_currentTime(0),
m_currentUITime(0)
{
}
Private(const Private &rhs, KisImage *newImage)
: image(newImage),
externalFrameActive(false),
frameInvalidationBlocked(false),
fullClipRange(rhs.fullClipRange),
playbackRange(rhs.playbackRange),
framerate(rhs.framerate),
cachedLastFrameValue(-1),
audioChannelFileName(rhs.audioChannelFileName),
audioChannelMuted(rhs.audioChannelMuted),
audioChannelVolume(rhs.audioChannelVolume),
m_currentTime(rhs.m_currentTime),
m_currentUITime(rhs.m_currentUITime)
{
}
KisImage *image;
bool externalFrameActive;
bool frameInvalidationBlocked;
KisTimeRange fullClipRange;
KisTimeRange playbackRange;
int framerate;
int cachedLastFrameValue;
QString audioChannelFileName;
bool audioChannelMuted;
qreal audioChannelVolume;
KisSwitchTimeStrokeStrategy::SharedTokenWSP switchToken;
inline int currentTime() const {
return m_currentTime;
}
inline int currentUITime() const {
return m_currentUITime;
}
inline void setCurrentTime(int value) {
m_currentTime = value;
}
inline void setCurrentUITime(int value) {
m_currentUITime = value;
}
private:
int m_currentTime;
int m_currentUITime;
};
KisImageAnimationInterface::KisImageAnimationInterface(KisImage *image)
: QObject(image),
m_d(new Private)
{
m_d->image = image;
m_d->framerate = 24;
m_d->fullClipRange = KisTimeRange::fromTime(0, 100);
connect(this, SIGNAL(sigInternalRequestTimeSwitch(int,bool)), SLOT(switchCurrentTimeAsync(int,bool)));
}
KisImageAnimationInterface::KisImageAnimationInterface(const KisImageAnimationInterface &rhs, KisImage *newImage)
: m_d(new Private(*rhs.m_d, newImage))
{
connect(this, SIGNAL(sigInternalRequestTimeSwitch(int,bool)), SLOT(switchCurrentTimeAsync(int,bool)));
}
KisImageAnimationInterface::~KisImageAnimationInterface()
{
}
bool KisImageAnimationInterface::hasAnimation() const
{
bool hasAnimation = false;
KisLayerUtils::recursiveApplyNodes(
m_d->image->root(),
[&hasAnimation](KisNodeSP node) {
hasAnimation |= node->isAnimated();
});
return hasAnimation;
}
int KisImageAnimationInterface::currentTime() const
{
return m_d->currentTime();
}
int KisImageAnimationInterface::currentUITime() const
{
return m_d->currentUITime();
}
const KisTimeRange& KisImageAnimationInterface::fullClipRange() const
{
return m_d->fullClipRange;
}
void KisImageAnimationInterface::setFullClipRange(const KisTimeRange range)
{
KIS_SAFE_ASSERT_RECOVER_RETURN(!range.isInfinite());
m_d->fullClipRange = range;
emit sigFullClipRangeChanged();
}
void KisImageAnimationInterface::setFullClipRangeStartTime(int column)
{
KisTimeRange newRange(column, m_d->fullClipRange.end(), false);
setFullClipRange(newRange);
}
void KisImageAnimationInterface::setFullClipRangeEndTime(int column)
{
KisTimeRange newRange(m_d->fullClipRange.start(), column, false);
setFullClipRange(newRange);
}
const KisTimeRange& KisImageAnimationInterface::playbackRange() const
{
return m_d->playbackRange.isValid() ? m_d->playbackRange : m_d->fullClipRange;
}
void KisImageAnimationInterface::setPlaybackRange(const KisTimeRange range)
{
KIS_SAFE_ASSERT_RECOVER_RETURN(!range.isInfinite());
m_d->playbackRange = range;
emit sigPlaybackRangeChanged();
}
int KisImageAnimationInterface::framerate() const
{
return m_d->framerate;
}
QString KisImageAnimationInterface::audioChannelFileName() const
{
return m_d->audioChannelFileName;
}
void KisImageAnimationInterface::setAudioChannelFileName(const QString &fileName)
{
QFileInfo info(fileName);
KIS_SAFE_ASSERT_RECOVER_NOOP(fileName.isEmpty() || info.isAbsolute());
m_d->audioChannelFileName = fileName.isEmpty() ? fileName : info.absoluteFilePath();
emit sigAudioChannelChanged();
}
bool KisImageAnimationInterface::isAudioMuted() const
{
return m_d->audioChannelMuted;
}
void KisImageAnimationInterface::setAudioMuted(bool value)
{
m_d->audioChannelMuted = value;
emit sigAudioChannelChanged();
}
qreal KisImageAnimationInterface::audioVolume() const
{
return m_d->audioChannelVolume;
}
void KisImageAnimationInterface::setAudioVolume(qreal value)
{
m_d->audioChannelVolume = value;
emit sigAudioVolumeChanged();
}
void KisImageAnimationInterface::setFramerate(int fps)
{
+ KIS_SAFE_ASSERT_RECOVER_RETURN(fps > 0);
+
m_d->framerate = fps;
emit sigFramerateChanged();
}
KisImageWSP KisImageAnimationInterface::image() const
{
return m_d->image;
}
bool KisImageAnimationInterface::externalFrameActive() const
{
return m_d->externalFrameActive;
}
void KisImageAnimationInterface::requestTimeSwitchWithUndo(int time)
{
if (currentUITime() == time) return;
requestTimeSwitchNonGUI(time, true);
}
void KisImageAnimationInterface::setDefaultProjectionColor(const KoColor &color)
{
int savedTime = 0;
saveAndResetCurrentTime(currentTime(), &savedTime);
m_d->image->setDefaultProjectionColor(color);
restoreCurrentTime(&savedTime);
}
void KisImageAnimationInterface::requestTimeSwitchNonGUI(int time, bool useUndo)
{
emit sigInternalRequestTimeSwitch(time, useUndo);
}
void KisImageAnimationInterface::explicitlySetCurrentTime(int frameId)
{
m_d->setCurrentTime(frameId);
}
void KisImageAnimationInterface::switchCurrentTimeAsync(int frameId, bool useUndo)
{
if (currentUITime() == frameId) return;
const KisTimeRange range = KisTimeRange::calculateIdenticalFramesRecursive(m_d->image->root(), currentUITime());
const bool needsRegeneration = !range.contains(frameId);
KisSwitchTimeStrokeStrategy::SharedTokenSP token =
m_d->switchToken.toStrongRef();
if (!token || !token->tryResetDestinationTime(frameId, needsRegeneration)) {
{
KisPostExecutionUndoAdapter *undoAdapter = useUndo ?
m_d->image->postExecutionUndoAdapter() : 0;
KisSwitchTimeStrokeStrategy *strategy =
new KisSwitchTimeStrokeStrategy(frameId, needsRegeneration,
this, undoAdapter);
m_d->switchToken = strategy->token();
KisStrokeId stroke = m_d->image->startStroke(strategy);
m_d->image->endStroke(stroke);
}
if (needsRegeneration) {
KisStrokeStrategy *strategy =
new KisRegenerateFrameStrokeStrategy(this);
KisStrokeId strokeId = m_d->image->startStroke(strategy);
m_d->image->endStroke(strokeId);
}
}
m_d->setCurrentUITime(frameId);
emit sigUiTimeChanged(frameId);
}
void KisImageAnimationInterface::requestFrameRegeneration(int frameId, const KisRegion &dirtyRegion)
{
KisStrokeStrategy *strategy =
new KisRegenerateFrameStrokeStrategy(frameId,
dirtyRegion,
this);
QList jobs = KisRegenerateFrameStrokeStrategy::createJobsData(m_d->image);
KisStrokeId stroke = m_d->image->startStroke(strategy);
Q_FOREACH (KisStrokeJobData* job, jobs) {
m_d->image->addJob(stroke, job);
}
m_d->image->endStroke(stroke);
}
void KisImageAnimationInterface::saveAndResetCurrentTime(int frameId, int *savedValue)
{
m_d->externalFrameActive = true;
*savedValue = m_d->currentTime();
m_d->setCurrentTime(frameId);
}
void KisImageAnimationInterface::restoreCurrentTime(int *savedValue)
{
m_d->setCurrentTime(*savedValue);
m_d->externalFrameActive = false;
}
void KisImageAnimationInterface::notifyFrameReady()
{
emit sigFrameReady(m_d->currentTime());
}
void KisImageAnimationInterface::notifyFrameCancelled()
{
emit sigFrameCancelled();
}
KisUpdatesFacade* KisImageAnimationInterface::updatesFacade() const
{
return m_d->image;
}
void KisImageAnimationInterface::notifyNodeChanged(const KisNode *node,
const QRect &rect,
bool recursive)
{
notifyNodeChanged(node, QVector({rect}), recursive);
}
void KisImageAnimationInterface::notifyNodeChanged(const KisNode *node,
const QVector &rects,
bool recursive)
{
if (externalFrameActive() || m_d->frameInvalidationBlocked) return;
// even overlay selection masks are not rendered in the cache
if (node->inherits("KisSelectionMask")) return;
const int currentTime = m_d->currentTime();
KisTimeRange invalidateRange;
if (recursive) {
invalidateRange = KisTimeRange::calculateAffectedFramesRecursive(node, currentTime);
} else {
invalidateRange = KisTimeRange::calculateNodeAffectedFrames(node, currentTime);
}
// we compress the updated rect (atm, no one uses it anyway)
QRect unitedRect;
Q_FOREACH (const QRect &rc, rects) {
unitedRect |= rc;
}
invalidateFrames(invalidateRange, unitedRect);
}
void KisImageAnimationInterface::invalidateFrames(const KisTimeRange &range, const QRect &rect)
{
m_d->cachedLastFrameValue = -1;
emit sigFramesChanged(range, rect);
}
void KisImageAnimationInterface::blockFrameInvalidation(bool value)
{
m_d->frameInvalidationBlocked = value;
}
int findLastKeyframeTimeRecursive(KisNodeSP node)
{
int time = 0;
KisKeyframeChannel *channel;
Q_FOREACH (channel, node->keyframeChannels()) {
KisKeyframeSP keyframe = channel->lastKeyframe();
if (keyframe) {
time = std::max(time, keyframe->time());
}
}
KisNodeSP child = node->firstChild();
while (child) {
time = std::max(time, findLastKeyframeTimeRecursive(child));
child = child->nextSibling();
}
return time;
}
int KisImageAnimationInterface::totalLength()
{
if (m_d->cachedLastFrameValue < 0) {
m_d->cachedLastFrameValue = findLastKeyframeTimeRecursive(m_d->image->root());
}
int lastKey = m_d->cachedLastFrameValue;
lastKey = std::max(lastKey, m_d->fullClipRange.end());
lastKey = std::max(lastKey, m_d->currentUITime());
return lastKey + 1;
}
diff --git a/libs/ui/widgets/kis_transport_controls.cpp b/libs/ui/widgets/kis_transport_controls.cpp
index 40380193aa..f1387365e3 100644
--- a/libs/ui/widgets/kis_transport_controls.cpp
+++ b/libs/ui/widgets/kis_transport_controls.cpp
@@ -1,69 +1,74 @@
/*
* Copyright (c) 2020 Emmet O'Neill
* Copyright (c) 2020 Eoin O'Neill
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_transport_controls.h"
#include
#include
#include "kis_icon.h"
+#include "klocalizedstring.h"
KisTransportControls::KisTransportControls(QWidget* parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(parent);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
buttonBack = new QPushButton(KisIconUtils::loadIcon("prevframe"), "", this);
+ buttonBack->setToolTip(i18n("Back"));
layout->addWidget(buttonBack);
connect(buttonBack, SIGNAL(released()), this, SIGNAL(back()));
buttonStop = new QPushButton(KisIconUtils::loadIcon("animation_stop"), "", this);
+ buttonStop->setToolTip(i18n("Stop"));
layout->addWidget(buttonStop);
connect(buttonStop, SIGNAL(released()), this, SIGNAL(stop()));
buttonPlayPause = new QPushButton(KisIconUtils::loadIcon("animation_play"), "", this);
+ buttonPlayPause->setToolTip(i18n("Play/Pause"));
layout->addWidget(buttonPlayPause);
connect(buttonPlayPause, SIGNAL(released()), this, SIGNAL(playPause()));
buttonForward = new QPushButton(KisIconUtils::loadIcon("nextframe"), "", this);
+ buttonForward->setToolTip(i18n("Forward"));
layout->addWidget(buttonForward);
connect(buttonForward, SIGNAL(released()), this, SIGNAL(forward()));
setLayout(layout);
}
KisTransportControls::~KisTransportControls()
{
}
QSize KisTransportControls::sizeHint() const
{
return QSize(32, 32);
}
void KisTransportControls::setPlaying(bool playing)
{
if (playing) {
buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_pause"));
} else {
buttonPlayPause->setIcon(KisIconUtils::loadIcon("animation_play"));
}
}
diff --git a/libs/ui/widgets/kis_utility_title_bar.h b/libs/ui/widgets/kis_utility_title_bar.h
index ff2aa156f1..28b188d388 100644
--- a/libs/ui/widgets/kis_utility_title_bar.h
+++ b/libs/ui/widgets/kis_utility_title_bar.h
@@ -1,53 +1,57 @@
/*
* Copyright (c) 2020 Emmet O'Neill
* Copyright (c) 2020 Eoin O'Neill
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISUTILITYTITLEBAR_H
#define KISUTILITYTITLEBAR_H
#include
+#ifdef Q_OS_MACOS
+#include
+#endif
+
#include "kritaui_export.h"
class QLabel;
class QHBoxLayout;
class QPushButton;
class KRITAUI_EXPORT KisUtilityTitleBar : public QWidget
{
Q_OBJECT
public:
KisUtilityTitleBar(QWidget *parent = nullptr);
KisUtilityTitleBar(QLabel *title, QWidget *parent = nullptr);
virtual QSize sizeHint() const {return QSize(32,32);}
virtual QSize minimumSizeHint() const {return QSize(32,32);}
protected:
QLabel *title;
QHBoxLayout *widgetArea;
const u_int SPACING_UNIT = 16;
private:
QPushButton *floatButton;
QPushButton *closeButton;
};
#endif // KISUTILITYTITLEBAR_H
diff --git a/plugins/dockers/animation/animation_dockers.cpp b/plugins/dockers/animation/animation_dockers.cpp
index 037e778ef0..38ba8e9214 100644
--- a/plugins/dockers/animation/animation_dockers.cpp
+++ b/plugins/dockers/animation/animation_dockers.cpp
@@ -1,172 +1,172 @@
/*
* Copyright (c) 2015 Jouni Pentikäinen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "animation_dockers.h"
#include "animation_docker.h"
#include "timeline_docker.h"
#include "onion_skins_docker.h"
#include "kis_animation_curve_docker.h"
#include
#include
#include
#include "KisViewManager.h"
K_PLUGIN_FACTORY_WITH_JSON(AnimationDockersPluginFactory, "krita_animationdocker.json", registerPlugin();)
class AnimationDockerFactory : public KoDockFactoryBase {
public:
AnimationDockerFactory()
{
}
QString id() const override
{
return QString( "AnimationDocker" );
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
QDockWidget *createDockWidget() override
{
AnimationDocker *dockWidget = new AnimationDocker();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const override
{
return DockMinimized;
}
private:
};
class TimelineDockerFactory : public KoDockFactoryBase {
public:
TimelineDockerFactory()
{
}
QString id() const override
{
- return QString( "TimelineDocker" );
+ return QString( "AnimationTimelineDocker" );
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
QDockWidget *createDockWidget() override
{
TimelineDocker *dockWidget = new TimelineDocker();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const override
{
return DockMinimized;
}
private:
};
class OnionSkinsDockerFactory : public KoDockFactoryBase {
public:
OnionSkinsDockerFactory()
{
}
QString id() const override
{
return QString( "OnionSkinsDocker" );
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
QDockWidget *createDockWidget() override
{
OnionSkinsDocker *dockWidget = new OnionSkinsDocker();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const override
{
return DockMinimized;
}
private:
};
class AnimationCurvesDockerFactory : public KoDockFactoryBase {
public:
AnimationCurvesDockerFactory()
{
}
QString id() const override
{
return QString( "AnimationCurvesDocker" );
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
QDockWidget *createDockWidget() override
{
KisAnimationCurveDocker *dockWidget = new KisAnimationCurveDocker();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const override
{
return DockMinimized;
}
private:
};
AnimationDockersPlugin::AnimationDockersPlugin(QObject *parent, const QVariantList &)
: QObject(parent)
{
KoDockRegistry::instance()->add(new AnimationDockerFactory());
KoDockRegistry::instance()->add(new TimelineDockerFactory());
KoDockRegistry::instance()->add(new OnionSkinsDockerFactory());
KoDockRegistry::instance()->add(new AnimationCurvesDockerFactory());
}
AnimationDockersPlugin::~AnimationDockersPlugin()
{
m_view = 0;
}
#include "animation_dockers.moc"
diff --git a/plugins/dockers/animation/timeline_docker.cpp b/plugins/dockers/animation/timeline_docker.cpp
index bfbf8566b5..0787c70e97 100644
--- a/plugins/dockers/animation/timeline_docker.cpp
+++ b/plugins/dockers/animation/timeline_docker.cpp
@@ -1,375 +1,581 @@
/*
* Copyright (c) 2015 Jouni Pentikäinen
* Copyright (c) 2020 Emmet O'Neill
* Copyright (c) 2020 Eoin O'Neill
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "timeline_docker.h"
+#include
#include "QHBoxLayout"
+#include "QVBoxLayout"
+#include "QFormLayout"
#include "QLabel"
#include "QPushButton"
-#include "QSpinBox"
#include "QToolButton"
+#include "QMenu"
+#include "QWidgetAction"
+#include "krita_utils.h"
#include "kis_canvas2.h"
#include "kis_image.h"
#include
#include "KisViewManager.h"
#include "kis_paint_layer.h"
#include "KisDocument.h"
#include "kis_dummies_facade.h"
#include "kis_shape_controller.h"
#include "kis_action.h"
#include "kis_action_manager.h"
#include "kis_animation_player.h"
+#include "kis_animation_utils.h"
#include "kis_keyframe_channel.h"
#include "kis_image.h"
#include "timeline_frames_model.h"
#include "timeline_frames_view.h"
+#include "kis_time_range.h"
#include "kis_animation_frame_cache.h"
#include "kis_image_animation_interface.h"
#include "kis_signal_auto_connection.h"
#include "kis_node_manager.h"
#include "kis_transport_controls.h"
-
-#include
+#include "kis_int_parse_spin_box.h"
+#include "kis_slider_spin_box.h"
+#include "kis_signals_blocker.h"
TimelineDockerTitleBar::TimelineDockerTitleBar(QWidget* parent) :
KisUtilityTitleBar(new QLabel(i18n("Animation Timeline"), parent), parent)
{
// Transport Controls...
transport = new KisTransportControls(this);
widgetArea->addWidget(transport);
widgetArea->addSpacing(SPACING_UNIT);
- // Frame Counter...
- frameCounter = new QSpinBox(this);
- frameCounter->setPrefix("# ");
- frameCounter->setRange(0, MAX_FRAMES);
- widgetArea->addWidget(frameCounter);
+ // Frame Register...
+ frameRegister = new KisIntParseSpinBox(this);
+ frameRegister->setToolTip(i18n("Frame register"));
+ frameRegister->setPrefix("# ");
+ frameRegister->setRange(0, MAX_FRAMES);
+ widgetArea->addWidget(frameRegister);
widgetArea->addSpacing(SPACING_UNIT);
{ // Frame ops...
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setSpacing(0);
layout->setContentsMargins(0,0,0,0);
- //add keyframe..
btnAddKeyframe = new QToolButton(this);
layout->addWidget(btnAddKeyframe);
btnDuplicateKeyframe = new QToolButton(this);
layout->addWidget(btnDuplicateKeyframe);
- //remove keyframe..
btnRemoveKeyframe = new QToolButton(this);
layout->addWidget(btnRemoveKeyframe);
QWidget *widget = new QWidget();
widget->setLayout(layout);
widgetArea->addWidget(widget);
}
+ widgetArea->addSpacing(SPACING_UNIT);
+
+ btnDropFrames = new QToolButton(this);
+ widgetArea->addWidget(btnDropFrames);
+
+ sbSpeed = new KisSliderSpinBox(this);
+ sbSpeed->setRange(25, 200);
+ sbSpeed->setSingleStep(25);
+ sbSpeed->setValue(100);
+ sbSpeed->setPrefix("Speed: ");
+ sbSpeed->setSuffix(" %");
+ sbSpeed->setToolTip(i18n("Preview playback speed"));
+ widgetArea->addWidget(sbSpeed);
+
widgetArea->addStretch();
{ // Menus..
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setSpacing(0);
layout->setContentsMargins(0,0,0,0);
// Onion skins menu.
btnOnionSkinsMenu = new QPushButton(KisIconUtils::loadIcon("onion_skin_options"), "", this);
+ btnOnionSkinsMenu->setToolTip(i18n("Onion skins menu"));
layout->addWidget(btnOnionSkinsMenu);
// Audio menu..
btnAudioMenu = new QPushButton(KisIconUtils::loadIcon("audio-none"), "", this);
+ btnOnionSkinsMenu->setToolTip(i18n("Audio menu"));
+ btnAudioMenu->setDisabled(true);
layout->addWidget(btnAudioMenu);
- // Settings menu..
- btnSettingsMenu = new QPushButton(KisIconUtils::loadIcon("configure"),"", this);
- layout->addWidget(btnSettingsMenu);
+ { // Settings menu..
+ btnSettingsMenu = new QToolButton(this);
+ btnSettingsMenu->setIcon(KisIconUtils::loadIcon("configure"));
+ btnSettingsMenu->setToolTip(i18n("Animation settings menu"));
+
+ QWidget *settingsMenuWidget = new QWidget(this);
+ settingsMenuWidget->setLayout(new QHBoxLayout(settingsMenuWidget));
+
+ QWidget *fields = new QWidget(settingsMenuWidget);
+ QFormLayout *fieldsLayout = new QFormLayout(settingsMenuWidget);
+ fields->setLayout(fieldsLayout);
+
+ sbStartFrame = new KisIntParseSpinBox(settingsMenuWidget);
+ sbStartFrame->setMaximum(10000);
+ fieldsLayout->addRow(i18n("Clip Start: "), sbStartFrame);
+
+ sbEndFrame = new KisIntParseSpinBox(settingsMenuWidget);
+ sbEndFrame->setMaximum(10000);
+ fieldsLayout->addRow(i18n("Clip End: "), sbEndFrame);
+
+ sbFrameRate = new KisIntParseSpinBox(settingsMenuWidget);
+ sbFrameRate->setMinimum(0);
+ sbFrameRate->setMaximum(180);
+ fieldsLayout->addRow(i18n("Frame Rate: "), sbFrameRate);
+
+ QWidget *buttons = new QWidget(settingsMenuWidget);
+ buttons->setLayout(new QVBoxLayout(settingsMenuWidget));
+
+ btnAutoFrame = new QToolButton(settingsMenuWidget);
+ buttons->layout()->addWidget(btnAutoFrame);
+ buttons->layout()->setAlignment(Qt::AlignTop);
+
+ settingsMenuWidget->layout()->addWidget(fields);
+ settingsMenuWidget->layout()->addWidget(buttons);
+
+ layout->addWidget(btnSettingsMenu);
+
+ QMenu *settingsPopMenu = new QMenu(this);
+ QWidgetAction *settingsMenuAction = new QWidgetAction(this);
+ settingsMenuAction->setDefaultWidget(settingsMenuWidget);
+ settingsPopMenu->addAction(settingsMenuAction);
+
+ btnSettingsMenu->setPopupMode(QToolButton::InstantPopup);
+ btnSettingsMenu->setMenu(settingsPopMenu);
+ }
QWidget *widget = new QWidget();
widget->setLayout(layout);
widgetArea->addWidget(widget);
}
}
struct TimelineDocker::Private
{
Private(QWidget *parent)
: framesModel(new TimelineFramesModel(parent)),
framesView(new TimelineFramesView(parent)),
titlebar(new TimelineDockerTitleBar(parent)),
mainWindow(nullptr)
{
framesView->setModel(framesModel);
}
TimelineFramesModel *framesModel;
TimelineFramesView *framesView;
TimelineDockerTitleBar *titlebar;
QPointer canvas;
KisSignalAutoConnectionsStore canvasConnections;
KisMainWindow *mainWindow;
};
TimelineDocker::TimelineDocker()
- : QDockWidget(i18n("Timeline"))
+ : QDockWidget(i18n("Animation Timeline"))
, m_d(new Private(this))
{
setWidget(m_d->framesView);
setTitleBarWidget(m_d->titlebar);
connect(m_d->titlebar->transport, SIGNAL(back()), this, SLOT(previousFrame()));
connect(m_d->titlebar->transport, SIGNAL(stop()), this, SLOT(stop()));
connect(m_d->titlebar->transport, SIGNAL(playPause()), this, SLOT(playPause()));
connect(m_d->titlebar->transport, SIGNAL(forward()), this, SLOT(nextFrame()));
- connect(m_d->titlebar->frameCounter, SIGNAL(valueChanged(int)), SLOT(goToFrame(int)));
+ connect(m_d->titlebar->frameRegister, SIGNAL(valueChanged(int)), SLOT(goToFrame(int)));
+ connect(m_d->titlebar->sbStartFrame, SIGNAL(valueChanged(int)), SLOT(setStartFrame(int)));
+ connect(m_d->titlebar->sbEndFrame, SIGNAL(valueChanged(int)), SLOT(setEndFrame(int)));
+ connect(m_d->titlebar->sbFrameRate, SIGNAL(valueChanged(int)), SLOT(setFrameRate(int)));
+ connect(m_d->titlebar->sbSpeed, SIGNAL(valueChanged(int)), SLOT(setPlaybackSpeed(int)));
connect(m_d->titlebar->btnOnionSkinsMenu, &QPushButton::released, [this](){
if (m_d->mainWindow) {
QDockWidget *docker = m_d->mainWindow->dockWidget("OnionSkinsDocker");
if (docker) {
docker->setVisible(!docker->isVisible());
}
}
});
}
TimelineDocker::~TimelineDocker()
{
}
struct NodeManagerInterface : TimelineFramesModel::NodeManipulationInterface
{
NodeManagerInterface(KisNodeManager *manager) : m_manager(manager) {}
KisLayerSP addPaintLayer() const override {
return m_manager->createPaintLayer();
}
void removeNode(KisNodeSP node) const override {
m_manager->removeSingleNode(node);
}
bool setNodeProperties(KisNodeSP node, KisImageSP image, KisBaseNode::PropertyList properties) const override
{
return m_manager->trySetNodeProperties(node, image, properties);
}
private:
KisNodeManager *m_manager;
};
void TimelineDocker::setCanvas(KoCanvasBase * canvas)
{
if (m_d->canvas == canvas) return;
if (m_d->framesModel->hasConnectionToCanvas()) {
m_d->canvasConnections.clear();
m_d->framesModel->setDummiesFacade(0, 0, 0);
m_d->framesModel->setFrameCache(0);
m_d->framesModel->setAnimationPlayer(0);
m_d->framesModel->setNodeManipulationInterface(0);
}
if (m_d->canvas) {
m_d->canvas->disconnectCanvasObserver(this);
m_d->canvas->animationPlayer()->disconnect(this);
+
+ if(m_d->canvas->image()) {
+ m_d->canvas->image()->animationInterface()->disconnect(this);
+ }
}
m_d->canvas = dynamic_cast(canvas);
setEnabled(m_d->canvas != 0);
if(m_d->canvas) {
KisDocument *doc = static_cast(m_d->canvas->imageView()->document());
KisShapeController *kritaShapeController = dynamic_cast(doc->shapeController());
m_d->framesModel->setDummiesFacade(kritaShapeController,
m_d->canvas->image(),
m_d->canvas->viewManager()->nodeManager()->nodeDisplayModeAdapter());
updateFrameCache();
+
+ {
+ KisSignalsBlocker blocker(m_d->titlebar->sbStartFrame,
+ m_d->titlebar->sbEndFrame,
+ m_d->titlebar->sbFrameRate);
+
+ KisImageAnimationInterface *animinterface = m_d->canvas->image()->animationInterface();
+ m_d->titlebar->sbStartFrame->setValue(animinterface->fullClipRange().start());
+ m_d->titlebar->sbEndFrame->setValue(animinterface->fullClipRange().end());
+ m_d->titlebar->sbFrameRate->setValue(animinterface->framerate());
+ m_d->titlebar->sbSpeed->setValue(100);
+ m_d->titlebar->frameRegister->setValue(animinterface->currentTime());
+ }
+
+
m_d->framesModel->setAnimationPlayer(m_d->canvas->animationPlayer());
m_d->framesModel->setNodeManipulationInterface(
new NodeManagerInterface(m_d->canvas->viewManager()->nodeManager()));
m_d->canvasConnections.addConnection(
m_d->canvas->viewManager()->nodeManager(), SIGNAL(sigNodeActivated(KisNodeSP)),
m_d->framesModel, SLOT(slotCurrentNodeChanged(KisNodeSP)));
m_d->canvasConnections.addConnection(
m_d->framesModel, SIGNAL(requestCurrentNodeChanged(KisNodeSP)),
m_d->canvas->viewManager()->nodeManager(), SLOT(slotNonUiActivatedNode(KisNodeSP)));
m_d->framesModel->slotCurrentNodeChanged(m_d->canvas->viewManager()->activeNode());
m_d->canvasConnections.addConnection(
m_d->canvas->viewManager()->mainWindow(), SIGNAL(themeChanged()),
this, SLOT(handleThemeChange()));
m_d->canvasConnections.addConnection(
m_d->canvas, SIGNAL(sigCanvasEngineChanged()),
this, SLOT(updateFrameCache()));
- connect(m_d->canvas->image()->animationInterface(), SIGNAL(sigUiTimeChanged(int)), this, SLOT(updateFrameCounter()));
- connect(m_d->canvas->animationPlayer(), SIGNAL(sigFrameChanged()), this, SLOT(updateFrameCounter()));
- connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStopped()), this, SLOT(updateFrameCounter()));
+ connect(m_d->canvas->image()->animationInterface(), SIGNAL(sigUiTimeChanged(int)), this, SLOT(updateFrameRegister()));
+ connect(m_d->canvas->animationPlayer(), SIGNAL(sigFrameChanged()), this, SLOT(updateFrameRegister()));
+ connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStopped()), this, SLOT(updateFrameRegister()));
- connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStateChanged(bool)), m_d->titlebar->frameCounter, SLOT(setDisabled(bool)));
+ connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStateChanged(bool)), m_d->titlebar->frameRegister, SLOT(setDisabled(bool)));
connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStateChanged(bool)), m_d->titlebar->transport, SLOT(setPlaying(bool)));
+ connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStatisticsUpdated()), this, SLOT(updatePlaybackStatistics()));
- //connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStopped()), this, SLOT(updatePlayPauseIcon()));
- //connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStarted()), this, SLOT(updatePlayPauseIcon()));
- //connect(m_d->canvas->animationPlayer(), SIGNAL(sigPlaybackStatisticsUpdated()), this, SLOT(updateDropFramesIcon()));
+ connect(m_d->canvas->image()->animationInterface(), SIGNAL(sigFullClipRangeChanged()), SLOT(handleClipRangeChange()));
+ connect(m_d->canvas->image()->animationInterface(), SIGNAL(sigFramerateChanged()), SLOT(handleFrameRateChange()));
}
}
void TimelineDocker::handleThemeChange()
{
if (m_d->framesView) {
m_d->framesView->slotUpdateIcons();
}
}
void TimelineDocker::updateFrameCache()
{
m_d->framesModel->setFrameCache(m_d->canvas->frameCache());
}
-void TimelineDocker::updateFrameCounter()
+void TimelineDocker::updateFrameRegister()
{
if (!m_d->canvas && !m_d->canvas->image()) {
return;
}
const int frame = m_d->canvas->animationPlayer()->isPlaying() ?
m_d->canvas->animationPlayer()->visibleFrame() :
m_d->canvas->image()->animationInterface()->currentUITime();
- m_d->titlebar->frameCounter->setValue(frame);
+ m_d->titlebar->frameRegister->setValue(frame);
+}
+
+void TimelineDocker::updatePlaybackStatistics()
+{
+ qreal effectiveFps = 0.0;
+ qreal realFps = 0.0;
+ qreal framesDropped = 0.0;
+ bool isPlaying = false;
+
+ KisAnimationPlayer *player = m_d->canvas && m_d->canvas->animationPlayer() ? m_d->canvas->animationPlayer() : 0;
+ if (player) {
+ effectiveFps = player->effectiveFps();
+ realFps = player->realFps();
+ framesDropped = player->framesDroppedPortion();
+ isPlaying = player->isPlaying();
+ }
+
+ KisConfig cfg(true);
+ const bool shouldDropFrames = cfg.animationDropFrames();
+
+ QAction *action = m_d->titlebar->btnDropFrames->defaultAction();
+ const bool droppingFrames = shouldDropFrames && framesDropped > 0.05;
+ action->setIcon(KisIconUtils::loadIcon(droppingFrames ? "droppedframes" : "dropframe"));
+
+ QString actionText;
+ if (!isPlaying) {
+ actionText = QString("%1 (%2) \n%3")
+ .arg(KisAnimationUtils::dropFramesActionName)
+ .arg(KritaUtils::toLocalizedOnOff(shouldDropFrames))
+ .arg(i18n("Enable to preserve playback timing."));
+ } else {
+ actionText = QString("%1 (%2)\n"
+ "%3\n"
+ "%4\n"
+ "%5")
+ .arg(KisAnimationUtils::dropFramesActionName)
+ .arg(KritaUtils::toLocalizedOnOff(shouldDropFrames))
+ .arg(i18n("Effective FPS:\t%1", effectiveFps))
+ .arg(i18n("Real FPS:\t%1", realFps))
+ .arg(i18n("Frames dropped:\t%1\%", framesDropped * 100));
+ }
+ action->setText(actionText);
}
void TimelineDocker::unsetCanvas()
{
setCanvas(0);
}
void TimelineDocker::setViewManager(KisViewManager *view)
{
m_d->mainWindow = view->mainWindow();
KisActionManager *actionManager = view->actionManager();
m_d->framesView->setActionManager(actionManager);
KisAction *action = 0;
TimelineDockerTitleBar* titleBar = static_cast(titleBarWidget());
action = actionManager->actionByName("add_blank_frame");
titleBar->btnAddKeyframe->setDefaultAction(action);
action = actionManager->actionByName("add_duplicate_frame");
titleBar->btnDuplicateKeyframe->setDefaultAction(action);
action = actionManager->actionByName("remove_frames");
titleBar->btnRemoveKeyframe->setDefaultAction(action);
action = actionManager->createAction("toggle_playback");
action->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(action, SIGNAL(triggered(bool)), SLOT(playPause()));
action = actionManager->createAction("stop_playback");
action->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(action, SIGNAL(triggered(bool)), SLOT(stop()));
action = actionManager->createAction("previous_frame");
action->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(action, SIGNAL(triggered(bool)), SLOT(previousFrame()));
action = actionManager->createAction("next_frame");
action->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(action, SIGNAL(triggered(bool)), SLOT(nextFrame()));
+
+ action = actionManager->createAction("lazy_frame");
+ m_d->titlebar->btnAutoFrame->setDefaultAction(action);
+
+ action = actionManager->createAction("drop_frames");
+ m_d->titlebar->btnDropFrames->setDefaultAction(action);
+ connect(action, SIGNAL(triggered(bool)), SLOT(setDropFrames(bool)));
+
+ {
+ KisConfig config(true);
+ action->setChecked(config.animationDropFrames());
+ }
}
void TimelineDocker::playPause()
{
if (!m_d->canvas) return;
if (m_d->canvas->animationPlayer()->isPlaying()) {
m_d->canvas->animationPlayer()->pause();
} else {
m_d->canvas->animationPlayer()->play();
}
}
void TimelineDocker::stop()
{
if (!m_d->canvas) return;
if( m_d->canvas->animationPlayer()->isStopped()) {
m_d->canvas->animationPlayer()->goToStartFrame();
} else {
m_d->canvas->animationPlayer()->stop();
m_d->canvas->animationPlayer()->goToPlaybackOrigin();
}
}
void TimelineDocker::previousFrame()
{
if (!m_d->canvas) return;
KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
int time = animInterface->currentUITime() - 1;
if (time >= 0) {
animInterface->requestTimeSwitchWithUndo(time);
}
}
void TimelineDocker::nextFrame()
{
if (!m_d->canvas) return;
KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
int time = animInterface->currentUITime() + 1;
animInterface->requestTimeSwitchWithUndo(time);
}
void TimelineDocker::goToFrame(int frameIndex)
{
- if (!m_d->canvas || !m_d->canvas->image()) return;
+ if (!m_d->canvas || !m_d->canvas->image()) return;
KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
if (m_d->canvas->animationPlayer()->isPlaying() ||
frameIndex == animInterface->currentUITime()) {
return;
}
animInterface->requestTimeSwitchWithUndo(frameIndex);
}
+
+void TimelineDocker::setStartFrame(int frame)
+{
+ if (!m_d->canvas || !m_d->canvas->image()) return;
+
+ KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
+
+ animInterface->setFullClipRangeStartTime(frame);
+}
+
+void TimelineDocker::setEndFrame(int frame)
+{
+ if (!m_d->canvas || !m_d->canvas->image()) return;
+
+ KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
+
+ animInterface->setFullClipRangeEndTime(frame);
+}
+
+void TimelineDocker::setFrameRate(int framerate)
+{
+ if (!m_d->canvas || !m_d->canvas->image()) return;
+
+ KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
+
+ animInterface->setFramerate(framerate);
+}
+
+void TimelineDocker::setPlaybackSpeed(int playbackSpeed)
+{
+ if (!m_d->canvas || !m_d->canvas->image()) return;
+
+ const float normalizedSpeed = playbackSpeed / 100.0;
+ m_d->canvas->animationPlayer()->slotUpdatePlaybackSpeed(normalizedSpeed);
+}
+
+void TimelineDocker::setDropFrames(bool dropFrames)
+{
+ KisConfig cfg(false);
+ cfg.setAnimationDropFrames(dropFrames);
+ updatePlaybackStatistics();
+}
+
+void TimelineDocker::handleClipRangeChange()
+{
+ if (!m_d->canvas || !m_d->canvas->image()) return;
+
+ KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
+
+ m_d->titlebar->sbStartFrame->setValue(animInterface->fullClipRange().start());
+ m_d->titlebar->sbEndFrame->setValue(animInterface->fullClipRange().end());
+}
+
+void TimelineDocker::handleFrameRateChange()
+{
+ if (!m_d->canvas || !m_d->canvas->image()) return;
+
+ KisImageAnimationInterface *animInterface = m_d->canvas->image()->animationInterface();
+
+ m_d->titlebar->sbFrameRate->setValue( m_d->canvas->image()->animationInterface()->framerate() );
+}
+
+
diff --git a/plugins/dockers/animation/timeline_docker.h b/plugins/dockers/animation/timeline_docker.h
index f1a830dc59..ed48990c43 100644
--- a/plugins/dockers/animation/timeline_docker.h
+++ b/plugins/dockers/animation/timeline_docker.h
@@ -1,93 +1,115 @@
/*
* Copyright (c) 2015 Jouni Pentikäinen
* Copyright (c) 2020 Emmet O'Neill
* Copyright (c) 2020 Eoin O'Neill
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _TIMELINE_DOCKER_H_
#define _TIMELINE_DOCKER_H_
#include "kritaimage_export.h"
#include
#include
#include
#include
+#ifdef Q_OS_MACOS
+#include
+#endif
+
class QPushButton;
class QToolButton;
-class QSpinBox;
class KisTransportControls;
+class KisIntParseSpinBox;
+class KisSliderSpinBox;
class KisCanvas2;
class KisAction;
class TimelineDockerTitleBar : public KisUtilityTitleBar
{
Q_OBJECT
public:
TimelineDockerTitleBar(QWidget *parent = nullptr);
KisTransportControls* transport;
- QSpinBox *frameCounter;
+ KisIntParseSpinBox *frameRegister;
QToolButton *btnAddKeyframe;
QToolButton *btnDuplicateKeyframe;
QToolButton *btnRemoveKeyframe;
QPushButton *btnOnionSkinsMenu;
QPushButton *btnAudioMenu;
- QPushButton *btnSettingsMenu;
+ QToolButton *btnSettingsMenu;
+
+ KisIntParseSpinBox *sbStartFrame;
+ KisIntParseSpinBox *sbEndFrame;
+ KisIntParseSpinBox *sbFrameRate;
+ KisSliderSpinBox *sbSpeed;
+ QToolButton *btnAutoFrame;
+ QToolButton *btnDropFrames;
private:
const u_int MAX_FRAMES = 9999;
};
class TimelineDocker : public QDockWidget, public KisMainwindowObserver
{
Q_OBJECT
public:
TimelineDocker();
~TimelineDocker() override;
- QString observerName() override { return "TimelineDocker"; }
+ QString observerName() override { return "AnimationTimelineDocker"; }
void setCanvas(KoCanvasBase *canvas) override;
void unsetCanvas() override;
void setViewManager(KisViewManager *kisview) override;
public Q_SLOTS:
void playPause();
void stop();
void previousFrame();
void nextFrame();
+
void goToFrame(int frameIndex);
+ void setStartFrame(int frame);
+ void setEndFrame(int frame);
+ void setFrameRate(int frmaerate);
+ void setPlaybackSpeed(int playbackSpeed);
+ void setDropFrames(bool dropFrames);
+
+ void handleClipRangeChange();
+ void handleFrameRateChange();
void updateFrameCache();
- void updateFrameCounter();
+ void updateFrameRegister();
+ void updatePlaybackStatistics();
void handleThemeChange();
private:
struct Private;
const QScopedPointer m_d;
};
#endif
diff --git a/plugins/dockers/animation/timeline_frames_view.cpp b/plugins/dockers/animation/timeline_frames_view.cpp
index 57fdd0407a..7cbb111be9 100644
--- a/plugins/dockers/animation/timeline_frames_view.cpp
+++ b/plugins/dockers/animation/timeline_frames_view.cpp
@@ -1,1575 +1,1566 @@
/*
* Copyright (c) 2015 Dmitry Kazakov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "timeline_frames_view.h"
#include "timeline_frames_model.h"
#include "timeline_ruler_header.h"
#include "timeline_layers_header.h"
#include "timeline_insert_keyframe_dialog.h"
#include "timeline_frames_item_delegate.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "config-qtmultimedia.h"
#include "KSharedConfig"
#include "KisKineticScroller.h"
#include "kis_zoom_button.h"
#include "kis_icon_utils.h"
#include "kis_animation_utils.h"
#include "kis_custom_modifiers_catcher.h"
#include "kis_action.h"
#include "kis_signal_compressor.h"
#include "kis_time_range.h"
#include "kis_color_label_selector_widget.h"
#include "kis_keyframe_channel.h"
#include "kis_slider_spin_box.h"
#include
#include
#include
#include
#include
typedef QPair QItemViewPaintPair;
typedef QList QItemViewPaintPairs;
struct TimelineFramesView::Private
{
Private(TimelineFramesView *_q)
: q(_q),
fps(1),
zoomStillPointIndex(-1),
zoomStillPointOriginalOffset(0),
dragInProgress(false),
dragWasSuccessful(false),
modifiersCatcher(0),
selectionChangedCompressor(300, KisSignalCompressor::FIRST_INACTIVE)
{}
TimelineFramesView *q;
TimelineFramesModel *model;
TimelineRulerHeader *horizontalRuler;
TimelineLayersHeader *layersHeader;
int fps;
int zoomStillPointIndex;
int zoomStillPointOriginalOffset;
QPoint initialDragPanValue;
QPoint initialDragPanPos;
QToolButton *addLayersButton;
KisAction *pinLayerToTimelineAction;
QToolButton *audioOptionsButton;
KisColorLabelSelectorWidget *colorSelector;
QWidgetAction *colorSelectorAction;
KisColorLabelSelectorWidget *multiframeColorSelector;
QWidgetAction *multiframeColorSelectorAction;
QMenu *audioOptionsMenu;
QAction *openAudioAction;
QAction *audioMuteAction;
KisSliderSpinBox *volumeSlider;
QMenu *layerEditingMenu;
QMenu *existingLayersMenu;
TimelineInsertKeyframeDialog *insertKeyframeDialog;
KisZoomButton *zoomDragButton;
bool dragInProgress;
bool dragWasSuccessful;
KisCustomModifiersCatcher *modifiersCatcher;
QPoint lastPressedPosition;
Qt::KeyboardModifiers lastPressedModifier;
KisSignalCompressor selectionChangedCompressor;
QStyleOptionViewItem viewOptionsV4() const;
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
QPixmap renderToPixmap(const QModelIndexList &indexes, QRect *r) const;
KisIconToolTip tip;
KisActionManager *actionMan = 0;
};
TimelineFramesView::TimelineFramesView(QWidget *parent)
: QTableView(parent),
m_d(new Private(this))
{
m_d->modifiersCatcher = new KisCustomModifiersCatcher(this);
m_d->modifiersCatcher->addModifier("pan-zoom", Qt::Key_Space);
m_d->modifiersCatcher->addModifier("offset-frame", Qt::Key_Alt);
setCornerButtonEnabled(false);
setSelectionBehavior(QAbstractItemView::SelectItems);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setItemDelegate(new TimelineFramesItemDelegate(this));
setDragEnabled(true);
setDragDropMode(QAbstractItemView::DragDrop);
setAcceptDrops(true);
setDropIndicatorShown(true);
setDefaultDropAction(Qt::MoveAction);
m_d->horizontalRuler = new TimelineRulerHeader(this);
this->setHorizontalHeader(m_d->horizontalRuler);
connect(m_d->horizontalRuler, SIGNAL(sigInsertColumnLeft()), SLOT(slotInsertKeyframeColumnLeft()));
connect(m_d->horizontalRuler, SIGNAL(sigInsertColumnRight()), SLOT(slotInsertKeyframeColumnRight()));
connect(m_d->horizontalRuler, SIGNAL(sigInsertMultipleColumns()), SLOT(slotInsertMultipleKeyframeColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigRemoveColumns()), SLOT(slotRemoveSelectedColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigRemoveColumnsAndShift()), SLOT(slotRemoveSelectedColumnsAndShift()));
connect(m_d->horizontalRuler, SIGNAL(sigInsertHoldColumns()), SLOT(slotInsertHoldFrameColumn()));
connect(m_d->horizontalRuler, SIGNAL(sigRemoveHoldColumns()), SLOT(slotRemoveHoldFrameColumn()));
connect(m_d->horizontalRuler, SIGNAL(sigInsertHoldColumnsCustom()), SLOT(slotInsertMultipleHoldFrameColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigRemoveHoldColumnsCustom()), SLOT(slotRemoveMultipleHoldFrameColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigMirrorColumns()), SLOT(slotMirrorColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigCopyColumns()), SLOT(slotCopyColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigCutColumns()), SLOT(slotCutColumns()));
connect(m_d->horizontalRuler, SIGNAL(sigPasteColumns()), SLOT(slotPasteColumns()));
m_d->layersHeader = new TimelineLayersHeader(this);
m_d->layersHeader->setSectionResizeMode(QHeaderView::Fixed);
m_d->layersHeader->setDefaultSectionSize(24);
m_d->layersHeader->setMinimumWidth(60);
m_d->layersHeader->setHighlightSections(true);
this->setVerticalHeader(m_d->layersHeader);
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), SLOT(slotUpdateInfiniteFramesCount()));
connect(horizontalScrollBar(), SIGNAL(sliderReleased()), SLOT(slotUpdateInfiniteFramesCount()));
/********** Layer Menu ***********************************************************/
m_d->layerEditingMenu = new QMenu(this);
m_d->layerEditingMenu->addSection(i18n("Edit Layers:"));
m_d->layerEditingMenu->addSeparator();
m_d->layerEditingMenu->addAction(KisAnimationUtils::newLayerActionName, this, SLOT(slotAddNewLayer()));
m_d->layerEditingMenu->addAction(KisAnimationUtils::removeLayerActionName, this, SLOT(slotRemoveLayer()));
m_d->layerEditingMenu->addSeparator();
m_d->existingLayersMenu = m_d->layerEditingMenu->addMenu(KisAnimationUtils::pinExistingLayerActionName);
connect(m_d->existingLayersMenu, SIGNAL(aboutToShow()), SLOT(slotUpdateLayersMenu()));
connect(m_d->existingLayersMenu, SIGNAL(triggered(QAction*)), SLOT(slotAddExistingLayer(QAction*)));
connect(m_d->layersHeader, SIGNAL(sigRequestContextMenu(QPoint)), SLOT(slotLayerContextMenuRequested(QPoint)));
m_d->addLayersButton = new QToolButton(this);
m_d->addLayersButton->setAutoRaise(true);
m_d->addLayersButton->setIcon(KisIconUtils::loadIcon("addlayer"));
m_d->addLayersButton->setIconSize(QSize(20, 20));
m_d->addLayersButton->setPopupMode(QToolButton::InstantPopup);
m_d->addLayersButton->setMenu(m_d->layerEditingMenu);
/********** Audio Channel Menu *******************************************************/
m_d->audioOptionsButton = new QToolButton(this);
m_d->audioOptionsButton->setAutoRaise(true);
m_d->audioOptionsButton->setIcon(KisIconUtils::loadIcon("audio-none"));
m_d->audioOptionsButton->setIconSize(QSize(20, 20)); // very small on windows if not explicitly set
m_d->audioOptionsButton->setPopupMode(QToolButton::InstantPopup);
m_d->audioOptionsMenu = new QMenu(this);
m_d->audioOptionsMenu->addSection(i18n("Edit Audio:"));
m_d->audioOptionsMenu->addSeparator();
#ifndef HAVE_QT_MULTIMEDIA
m_d->audioOptionsMenu->addSection(i18nc("@item:inmenu", "Audio playback is not supported in this build!"));
#endif
m_d->openAudioAction= new QAction("XXX", this);
connect(m_d->openAudioAction, SIGNAL(triggered()), this, SLOT(slotSelectAudioChannelFile()));
m_d->audioOptionsMenu->addAction(m_d->openAudioAction);
m_d->audioMuteAction = new QAction(i18nc("@item:inmenu", "Mute"), this);
m_d->audioMuteAction->setCheckable(true);
connect(m_d->audioMuteAction, SIGNAL(triggered(bool)), SLOT(slotAudioChannelMute(bool)));
m_d->audioOptionsMenu->addAction(m_d->audioMuteAction);
m_d->audioOptionsMenu->addAction(i18nc("@item:inmenu", "Remove audio"), this, SLOT(slotAudioChannelRemove()));
m_d->audioOptionsMenu->addSeparator();
m_d->volumeSlider = new KisSliderSpinBox(this);
m_d->volumeSlider->setRange(0, 100);
m_d->volumeSlider->setSuffix(i18n("%"));
m_d->volumeSlider->setPrefix(i18nc("@item:inmenu, slider", "Volume:"));
m_d->volumeSlider->setSingleStep(1);
m_d->volumeSlider->setPageStep(10);
m_d->volumeSlider->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
connect(m_d->volumeSlider, SIGNAL(valueChanged(int)), SLOT(slotAudioVolumeChanged(int)));
QWidgetAction *volumeAction = new QWidgetAction(m_d->audioOptionsMenu);
volumeAction->setDefaultWidget(m_d->volumeSlider);
m_d->audioOptionsMenu->addAction(volumeAction);
m_d->audioOptionsButton->setMenu(m_d->audioOptionsMenu);
/********** Frame Editing Context Menu ***********************************************/
m_d->colorSelector = new KisColorLabelSelectorWidget(this);
m_d->colorSelectorAction = new QWidgetAction(this);
m_d->colorSelectorAction->setDefaultWidget(m_d->colorSelector);
connect(m_d->colorSelector, &KisColorLabelSelectorWidget::currentIndexChanged, this, &TimelineFramesView::slotColorLabelChanged);
m_d->multiframeColorSelector = new KisColorLabelSelectorWidget(this);
m_d->multiframeColorSelectorAction = new QWidgetAction(this);
m_d->multiframeColorSelectorAction->setDefaultWidget(m_d->multiframeColorSelector);
connect(m_d->multiframeColorSelector, &KisColorLabelSelectorWidget::currentIndexChanged, this, &TimelineFramesView::slotColorLabelChanged);
/********** Insert Keyframes Dialog **************************************************/
m_d->insertKeyframeDialog = new TimelineInsertKeyframeDialog(this);
/********** Zoom Button **************************************************************/
m_d->zoomDragButton = new KisZoomButton(this);
m_d->zoomDragButton->setAutoRaise(true);
m_d->zoomDragButton->setIcon(KisIconUtils::loadIcon("zoom-horizontal"));
m_d->zoomDragButton->setIconSize(QSize(20, 20)); // this icon is very small on windows if no explicitly set
m_d->zoomDragButton->setToolTip(i18nc("@info:tooltip", "Zoom Timeline. Hold down and drag left or right."));
m_d->zoomDragButton->setPopupMode(QToolButton::InstantPopup);
connect(m_d->zoomDragButton, SIGNAL(zoomLevelChanged(qreal)), SLOT(slotZoomButtonChanged(qreal)));
connect(m_d->zoomDragButton, SIGNAL(zoomStarted(qreal)), SLOT(slotZoomButtonPressed(qreal)));
setFramesPerSecond(12);
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
{
QScroller *scroller = KisKineticScroller::createPreconfiguredScroller(this);
if( scroller ) {
connect(scroller, SIGNAL(stateChanged(QScroller::State)),
this, SLOT(slotScrollerStateChanged(QScroller::State)));
}
}
connect(&m_d->selectionChangedCompressor, SIGNAL(timeout()),
SLOT(slotSelectionChanged()));
connect(&m_d->selectionChangedCompressor, SIGNAL(timeout()),
SLOT(slotUpdateFrameActions()));
{
QClipboard *cb = QApplication::clipboard();
connect(cb, SIGNAL(dataChanged()), SLOT(slotUpdateFrameActions()));
}
}
TimelineFramesView::~TimelineFramesView()
{
}
void TimelineFramesView::setActionManager(KisActionManager *actionManager)
{
m_d->actionMan = actionManager;
m_d->horizontalRuler->setActionManager(actionManager);
if (actionManager) {
KisAction *action = 0;
action = m_d->actionMan->createAction("add_blank_frame");
connect(action, SIGNAL(triggered()), SLOT(slotAddBlankFrame()));
action = m_d->actionMan->createAction("add_duplicate_frame");
connect(action, SIGNAL(triggered()), SLOT(slotAddDuplicateFrame()));
action = m_d->actionMan->createAction("insert_keyframe_left");
connect(action, SIGNAL(triggered()), SLOT(slotInsertKeyframeLeft()));
action = m_d->actionMan->createAction("insert_keyframe_right");
connect(action, SIGNAL(triggered()), SLOT(slotInsertKeyframeRight()));
action = m_d->actionMan->createAction("insert_multiple_keyframes");
connect(action, SIGNAL(triggered()), SLOT(slotInsertMultipleKeyframes()));
action = m_d->actionMan->createAction("remove_frames_and_pull");
connect(action, SIGNAL(triggered()), SLOT(slotRemoveSelectedFramesAndShift()));
action = m_d->actionMan->createAction("remove_frames");
connect(action, SIGNAL(triggered()), SLOT(slotRemoveSelectedFrames()));
action = m_d->actionMan->createAction("insert_hold_frame");
connect(action, SIGNAL(triggered()), SLOT(slotInsertHoldFrame()));
action = m_d->actionMan->createAction("insert_multiple_hold_frames");
connect(action, SIGNAL(triggered()), SLOT(slotInsertMultipleHoldFrames()));
action = m_d->actionMan->createAction("remove_hold_frame");
connect(action, SIGNAL(triggered()), SLOT(slotRemoveHoldFrame()));
action = m_d->actionMan->createAction("remove_multiple_hold_frames");
connect(action, SIGNAL(triggered()), SLOT(slotRemoveMultipleHoldFrames()));
action = m_d->actionMan->createAction("mirror_frames");
connect(action, SIGNAL(triggered()), SLOT(slotMirrorFrames()));
action = m_d->actionMan->createAction("copy_frames_to_clipboard");
connect(action, SIGNAL(triggered()), SLOT(slotCopyFrames()));
action = m_d->actionMan->createAction("cut_frames_to_clipboard");
connect(action, SIGNAL(triggered()), SLOT(slotCutFrames()));
action = m_d->actionMan->createAction("paste_frames_from_clipboard");
connect(action, SIGNAL(triggered()), SLOT(slotPasteFrames()));
action = m_d->actionMan->createAction("set_start_time");
connect(action, SIGNAL(triggered()), SLOT(slotSetStartTimeToCurrentPosition()));
action = m_d->actionMan->createAction("set_end_time");
connect(action, SIGNAL(triggered()), SLOT(slotSetEndTimeToCurrentPosition()));
action = m_d->actionMan->createAction("update_playback_range");
connect(action, SIGNAL(triggered()), SLOT(slotUpdatePlackbackRange()));
action = m_d->actionMan->actionByName("pin_to_timeline");
m_d->pinLayerToTimelineAction = action;
m_d->layerEditingMenu->addAction(action);
}
}
void resizeToMinimalSize(QAbstractButton *w, int minimalSize) {
QSize buttonSize = w->sizeHint();
if (buttonSize.height() > minimalSize) {
buttonSize = QSize(minimalSize, minimalSize);
}
w->resize(buttonSize);
}
void TimelineFramesView::updateGeometries()
{
QTableView::updateGeometries();
const int availableHeight = m_d->horizontalRuler->height();
const int margin = 2;
const int minimalSize = availableHeight - 2 * margin;
resizeToMinimalSize(m_d->addLayersButton, minimalSize);
resizeToMinimalSize(m_d->audioOptionsButton, minimalSize);
resizeToMinimalSize(m_d->zoomDragButton, minimalSize);
int x = 2 * margin;
int y = (availableHeight - minimalSize) / 2;
m_d->addLayersButton->move(x, 2 * y);
m_d->audioOptionsButton->move(x + minimalSize + 2 * margin, 2 * y);
const int availableWidth = m_d->layersHeader->width();
x = availableWidth - margin - minimalSize;
m_d->zoomDragButton->move(x, 2 * y);
}
void TimelineFramesView::setModel(QAbstractItemModel *model)
{
TimelineFramesModel *framesModel = qobject_cast(model);
m_d->model = framesModel;
QTableView::setModel(model);
connect(m_d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
this, SLOT(slotHeaderDataChanged(Qt::Orientation,int,int)));
connect(m_d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
connect(m_d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(slotReselectCurrentIndex()));
connect(m_d->model, SIGNAL(sigInfiniteTimelineUpdateNeeded()),
this, SLOT(slotUpdateInfiniteFramesCount()));
connect(m_d->model, SIGNAL(sigAudioChannelChanged()),
this, SLOT(slotUpdateAudioActions()));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
&m_d->selectionChangedCompressor, SLOT(start()));
connect(m_d->model, SIGNAL(sigEnsureRowVisible(int)), SLOT(slotEnsureRowVisible(int)));
slotUpdateAudioActions();
}
void TimelineFramesView::setFramesPerSecond(int fps)
{
m_d->fps = fps;
m_d->horizontalRuler->setFramePerSecond(fps);
// For some reason simple update sometimes doesn't work here, so
// reset the whole header
//
// m_d->horizontalRuler->reset();
}
void TimelineFramesView::slotZoomButtonPressed(qreal staticPoint)
{
m_d->zoomStillPointIndex =
qIsNaN(staticPoint) ? currentIndex().column() : staticPoint;
const int w = m_d->horizontalRuler->defaultSectionSize();
m_d->zoomStillPointOriginalOffset =
w * m_d->zoomStillPointIndex -
horizontalScrollBar()->value();
}
void TimelineFramesView::slotZoomButtonChanged(qreal zoomLevel)
{
if (m_d->horizontalRuler->setZoom(zoomLevel)) {
slotUpdateInfiniteFramesCount();
const int w = m_d->horizontalRuler->defaultSectionSize();
horizontalScrollBar()->setValue(w * m_d->zoomStillPointIndex - m_d->zoomStillPointOriginalOffset);
viewport()->update();
}
}
void TimelineFramesView::slotColorLabelChanged(int label)
{
Q_FOREACH(QModelIndex index, selectedIndexes()) {
m_d->model->setData(index, label, TimelineFramesModel::FrameColorLabelIndexRole);
}
KisImageConfig(false).setDefaultFrameColorLabel(label);
}
void TimelineFramesView::slotSelectAudioChannelFile()
{
if (!m_d->model) return;
QString defaultDir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
const QString currentFile = m_d->model->audioChannelFileName();
QDir baseDir = QFileInfo(currentFile).absoluteDir();
if (baseDir.exists()) {
defaultDir = baseDir.absolutePath();
}
const QString result = KisImportExportManager::askForAudioFileName(defaultDir, this);
const QFileInfo info(result);
if (info.exists()) {
m_d->model->setAudioChannelFileName(info.absoluteFilePath());
}
}
void TimelineFramesView::slotAudioChannelMute(bool value)
{
if (!m_d->model) return;
if (value != m_d->model->isAudioMuted()) {
m_d->model->setAudioMuted(value);
}
}
void TimelineFramesView::slotUpdateIcons()
{
m_d->addLayersButton->setIcon(KisIconUtils::loadIcon("addlayer"));
m_d->audioOptionsButton->setIcon(KisIconUtils::loadIcon("audio-none"));
m_d->zoomDragButton->setIcon(KisIconUtils::loadIcon("zoom-horizontal"));
}
void TimelineFramesView::slotAudioChannelRemove()
{
if (!m_d->model) return;
m_d->model->setAudioChannelFileName(QString());
}
void TimelineFramesView::slotUpdateAudioActions()
{
if (!m_d->model) return;
const QString currentFile = m_d->model->audioChannelFileName();
if (currentFile.isEmpty()) {
m_d->openAudioAction->setText(i18nc("@item:inmenu", "Open audio..."));
} else {
QFileInfo info(currentFile);
m_d->openAudioAction->setText(i18nc("@item:inmenu", "Change audio (%1)...", info.fileName()));
}
m_d->audioMuteAction->setChecked(m_d->model->isAudioMuted());
QIcon audioIcon;
if (currentFile.isEmpty()) {
audioIcon = KisIconUtils::loadIcon("audio-none");
} else {
if (m_d->model->isAudioMuted()) {
audioIcon = KisIconUtils::loadIcon("audio-volume-mute");
} else {
audioIcon = KisIconUtils::loadIcon("audio-volume-high");
}
}
m_d->audioOptionsButton->setIcon(audioIcon);
m_d->volumeSlider->setEnabled(!m_d->model->isAudioMuted());
KisSignalsBlocker b(m_d->volumeSlider);
m_d->volumeSlider->setValue(qRound(m_d->model->audioVolume() * 100.0));
}
void TimelineFramesView::slotAudioVolumeChanged(int value)
{
m_d->model->setAudioVolume(qreal(value) / 100.0);
}
void TimelineFramesView::slotUpdateInfiniteFramesCount()
{
if (horizontalScrollBar()->isSliderDown()) return;
const int sectionWidth = m_d->horizontalRuler->defaultSectionSize();
const int calculatedIndex =
(horizontalScrollBar()->value() +
m_d->horizontalRuler->width() - 1) / sectionWidth;
m_d->model->setLastVisibleFrame(calculatedIndex);
}
void TimelineFramesView::slotScrollerStateChanged( QScroller::State state ) {
KisKineticScroller::updateCursor(this, state);
}
void TimelineFramesView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
QTableView::currentChanged(current, previous);
if (previous.column() != current.column()) {
m_d->model->setData(previous, false, TimelineFramesModel::ActiveFrameRole);
m_d->model->setData(current, true, TimelineFramesModel::ActiveFrameRole);
}
}
QItemSelectionModel::SelectionFlags TimelineFramesView::selectionCommand(const QModelIndex &index,
const QEvent *event) const
{
// WARNING: Copy-pasted from KisNodeView! Please keep in sync!
/**
* Qt has a bug: when we Ctrl+click on an item, the item's
* selections gets toggled on mouse *press*, whereas usually it is
* done on mouse *release*. Therefore the user cannot do a
* Ctrl+D&D with the default configuration. This code fixes the
* problem by manually returning QItemSelectionModel::NoUpdate
* flag when the user clicks on an item and returning
* QItemSelectionModel::Toggle on release.
*/
if (event &&
(event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease) &&
index.isValid()) {
const QMouseEvent *mevent = static_cast(event);
if (mevent->button() == Qt::RightButton &&
selectionModel()->selectedIndexes().contains(index)) {
// Allow calling context menu for multiple layers
return QItemSelectionModel::NoUpdate;
}
if (event->type() == QEvent::MouseButtonPress &&
(mevent->modifiers() & Qt::ControlModifier)) {
return QItemSelectionModel::NoUpdate;
}
if (event->type() == QEvent::MouseButtonRelease &&
(mevent->modifiers() & Qt::ControlModifier)) {
return QItemSelectionModel::Toggle;
}
}
return QAbstractItemView::selectionCommand(index, event);
}
void TimelineFramesView::slotSelectionChanged()
{
int minColumn = std::numeric_limits::max();
int maxColumn = std::numeric_limits::min();
foreach (const QModelIndex &idx, selectedIndexes()) {
if (idx.column() > maxColumn) {
maxColumn = idx.column();
}
if (idx.column() < minColumn) {
minColumn = idx.column();
}
}
KisTimeRange range;
if (maxColumn > minColumn) {
range = KisTimeRange(minColumn, maxColumn - minColumn + 1);
}
if (m_d->model->isPlaybackPaused()) {
m_d->model->stopPlayback();
}
m_d->model->setPlaybackRange(range);
}
void TimelineFramesView::slotReselectCurrentIndex()
{
QModelIndex index = currentIndex();
currentChanged(index, index);
}
void TimelineFramesView::slotEnsureRowVisible(int row)
{
QModelIndex index = currentIndex();
if (!index.isValid() || row < 0) return;
index = m_d->model->index(row, index.column());
scrollTo(index);
}
void TimelineFramesView::slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
if (m_d->model->isPlaybackActive()) return;
int selectedColumn = -1;
for (int j = topLeft.column(); j <= bottomRight.column(); j++) {
QVariant value = m_d->model->data(
m_d->model->index(topLeft.row(), j),
TimelineFramesModel::ActiveFrameRole);
if (value.isValid() && value.toBool()) {
selectedColumn = j;
break;
}
}
QModelIndex index = currentIndex();
if (!index.isValid() && selectedColumn < 0) {
return;
}
if (selectedColumn == -1) {
selectedColumn = index.column();
}
if (selectedColumn != index.column() && !m_d->dragInProgress) {
int row= index.isValid() ? index.row() : 0;
selectionModel()->setCurrentIndex(m_d->model->index(row, selectedColumn), QItemSelectionModel::ClearAndSelect);
}
}
void TimelineFramesView::slotHeaderDataChanged(Qt::Orientation orientation, int first, int last)
{
Q_UNUSED(first);
Q_UNUSED(last);
if (orientation == Qt::Horizontal) {
const int newFps = m_d->model->headerData(0, Qt::Horizontal, TimelineFramesModel::FramesPerSecondRole).toInt();
if (newFps != m_d->fps) {
setFramesPerSecond(newFps);
}
}
}
void TimelineFramesView::rowsInserted(const QModelIndex& parent, int start, int end)
{
QTableView::rowsInserted(parent, start, end);
}
inline bool isIndexDragEnabled(QAbstractItemModel *model, const QModelIndex &index) {
return (model->flags(index) & Qt::ItemIsDragEnabled);
}
QStyleOptionViewItem TimelineFramesView::Private::viewOptionsV4() const
{
QStyleOptionViewItem option = q->viewOptions();
option.locale = q->locale();
option.locale.setNumberOptions(QLocale::OmitGroupSeparator);
option.widget = q;
return option;
}
QItemViewPaintPairs TimelineFramesView::Private::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
{
Q_ASSERT(r);
QRect &rect = *r;
const QRect viewportRect = q->viewport()->rect();
QItemViewPaintPairs ret;
for (int i = 0; i < indexes.count(); ++i) {
const QModelIndex &index = indexes.at(i);
const QRect current = q->visualRect(index);
if (current.intersects(viewportRect)) {
ret += qMakePair(current, index);
rect |= current;
}
}
rect &= viewportRect;
return ret;
}
QPixmap TimelineFramesView::Private::renderToPixmap(const QModelIndexList &indexes, QRect *r) const
{
Q_ASSERT(r);
QItemViewPaintPairs paintPairs = draggablePaintPairs(indexes, r);
if (paintPairs.isEmpty())
return QPixmap();
QPixmap pixmap(r->size());
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QStyleOptionViewItem option = viewOptionsV4();
option.state |= QStyle::State_Selected;
for (int j = 0; j < paintPairs.count(); ++j) {
option.rect = paintPairs.at(j).first.translated(-r->topLeft());
const QModelIndex ¤t = paintPairs.at(j).second;
//adjustViewOptionsForIndex(&option, current);
q->itemDelegate(current)->paint(&painter, option, current);
}
return pixmap;
}
void TimelineFramesView::startDrag(Qt::DropActions supportedActions)
{
QModelIndexList indexes = selectionModel()->selectedIndexes();
if (!indexes.isEmpty() && m_d->modifiersCatcher->modifierPressed("offset-frame")) {
QVector rows;
int leftmostColumn = std::numeric_limits::max();
Q_FOREACH (const QModelIndex &index, indexes) {
leftmostColumn = qMin(leftmostColumn, index.column());
if (!rows.contains(index.row())) {
rows.append(index.row());
}
}
const int lastColumn = m_d->model->columnCount() - 1;
selectionModel()->clear();
Q_FOREACH (const int row, rows) {
QItemSelection sel(m_d->model->index(row, leftmostColumn), m_d->model->index(row, lastColumn));
selectionModel()->select(sel, QItemSelectionModel::Select);
}
supportedActions = Qt::MoveAction;
{
QModelIndexList indexes = selectedIndexes();
for(int i = indexes.count() - 1 ; i >= 0; --i) {
if (!isIndexDragEnabled(m_d->model, indexes.at(i)))
indexes.removeAt(i);
}
selectionModel()->clear();
if (indexes.count() > 0) {
QMimeData *data = m_d->model->mimeData(indexes);
if (!data)
return;
QRect rect;
QPixmap pixmap = m_d->renderToPixmap(indexes, &rect);
rect.adjust(horizontalOffset(), verticalOffset(), 0, 0);
QDrag *drag = new QDrag(this);
drag->setPixmap(pixmap);
drag->setMimeData(data);
drag->setHotSpot(m_d->lastPressedPosition - rect.topLeft());
drag->exec(supportedActions, Qt::MoveAction);
setCurrentIndex(currentIndex());
}
}
} else {
/**
* Workaround for Qt5's bug: if we start a dragging action right during
* Shift-selection, Qt will get crazy. We cannot workaround it easily,
* because we would need to fork mouseMoveEvent() for that (where the
* decision about drag state is done). So we just abort dragging in that
* case.
*
* BUG:373067
*/
if (m_d->lastPressedModifier & Qt::ShiftModifier) {
return;
}
/**
* Workaround for Qt5's bugs:
*
* 1) Qt doesn't treat selection the selection on D&D
* correctly, so we save it in advance and restore
* afterwards.
*
* 2) There is a private variable in QAbstractItemView:
* QAbstractItemView::Private::currentSelectionStartIndex.
* It is initialized *only* when the setCurrentIndex() is called
* explicitly on the view object, not on the selection model.
* Therefore we should explicitly call setCurrentIndex() after
* D&D, even if it already has *correct* value!
*
* 2) We should also call selectionModel()->select()
* explicitly. There are two reasons for it: 1) Qt doesn't
* maintain selection over D&D; 2) when reselecting single
* element after D&D, Qt goes crazy, because it tries to
* read *global* keyboard modifiers. Therefore if we are
* dragging with Shift or Ctrl pressed it'll get crazy. So
* just reset it explicitly.
*/
QModelIndexList selectionBefore = selectionModel()->selectedIndexes();
QModelIndex currentBefore = selectionModel()->currentIndex();
// initialize a global status variable
m_d->dragWasSuccessful = false;
QAbstractItemView::startDrag(supportedActions);
QModelIndex newCurrent;
QPoint selectionOffset;
if (m_d->dragWasSuccessful) {
newCurrent = currentIndex();
selectionOffset = QPoint(newCurrent.column() - currentBefore.column(),
newCurrent.row() - currentBefore.row());
} else {
newCurrent = currentBefore;
selectionOffset = QPoint();
}
setCurrentIndex(newCurrent);
selectionModel()->clearSelection();
Q_FOREACH (const QModelIndex &idx, selectionBefore) {
QModelIndex newIndex =
model()->index(idx.row() + selectionOffset.y(),
idx.column() + selectionOffset.x());
selectionModel()->select(newIndex, QItemSelectionModel::Select);
}
}
}
void TimelineFramesView::dragEnterEvent(QDragEnterEvent *event)
{
m_d->dragInProgress = true;
m_d->model->setScrubState(true);
QTableView::dragEnterEvent(event);
}
void TimelineFramesView::dragMoveEvent(QDragMoveEvent *event)
{
m_d->dragInProgress = true;
m_d->model->setScrubState(true);
QTableView::dragMoveEvent(event);
if (event->isAccepted()) {
QModelIndex index = indexAt(event->pos());
if (!m_d->model->canDropFrameData(event->mimeData(), index)) {
event->ignore();
} else {
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
}
}
}
void TimelineFramesView::dropEvent(QDropEvent *event)
{
m_d->dragInProgress = false;
m_d->model->setScrubState(false);
if (event->keyboardModifiers() & Qt::ControlModifier) {
event->setDropAction(Qt::CopyAction);
}
QAbstractItemView::dropEvent(event);
m_d->dragWasSuccessful = event->isAccepted();
}
void TimelineFramesView::dragLeaveEvent(QDragLeaveEvent *event)
{
m_d->dragInProgress = false;
m_d->model->setScrubState(false);
QAbstractItemView::dragLeaveEvent(event);
}
void TimelineFramesView::createFrameEditingMenuActions(QMenu *menu, bool addFrameCreationActions)
{
slotUpdateFrameActions();
// calculate if selection range is set. This will determine if the update playback range is available
QSet rows;
int minColumn = 0;
int maxColumn = 0;
calculateSelectionMetrics(minColumn, maxColumn, rows);
bool selectionExists = minColumn != maxColumn;
menu->addSection(i18n("Edit Frames:"));
menu->addSeparator();
if (selectionExists) {
KisActionManager::safePopulateMenu(menu, "update_playback_range", m_d->actionMan);
} else {
KisActionManager::safePopulateMenu(menu, "set_start_time", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "set_end_time", m_d->actionMan);
}
menu->addSeparator();
KisActionManager::safePopulateMenu(menu, "cut_frames_to_clipboard", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "copy_frames_to_clipboard", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "paste_frames_from_clipboard", m_d->actionMan);
menu->addSeparator();
{ // Tween submenu.
QMenu *frames = menu->addMenu(i18nc("@item:inmenu", "Tweening"));
KisActionManager::safePopulateMenu(frames, "insert_opacity_keyframe", m_d->actionMan);
KisActionManager::safePopulateMenu(frames, "remove_opacity_keyframe", m_d->actionMan);
// only allow to add an opacity keyframe if one doesn't exist
bool opacityKeyframeExists = model()->data(currentIndex(), TimelineFramesModel::SpecialKeyframeExists).toBool();
m_d->actionMan->actionByName("insert_opacity_keyframe")->setEnabled(!opacityKeyframeExists);
m_d->actionMan->actionByName("remove_opacity_keyframe")->setEnabled(opacityKeyframeExists);
}
{ //Frames submenu.
QMenu *frames = menu->addMenu(i18nc("@item:inmenu", "Keyframes"));
KisActionManager::safePopulateMenu(frames, "insert_keyframe_left", m_d->actionMan);
KisActionManager::safePopulateMenu(frames, "insert_keyframe_right", m_d->actionMan);
frames->addSeparator();
KisActionManager::safePopulateMenu(frames, "insert_multiple_keyframes", m_d->actionMan);
}
{ //Holds submenu.
QMenu *hold = menu->addMenu(i18nc("@item:inmenu", "Hold Frames"));
KisActionManager::safePopulateMenu(hold, "insert_hold_frame", m_d->actionMan);
KisActionManager::safePopulateMenu(hold, "remove_hold_frame", m_d->actionMan);
hold->addSeparator();
KisActionManager::safePopulateMenu(hold, "insert_multiple_hold_frames", m_d->actionMan);
KisActionManager::safePopulateMenu(hold, "remove_multiple_hold_frames", m_d->actionMan);
}
menu->addSeparator();
KisActionManager::safePopulateMenu(menu, "remove_frames", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "remove_frames_and_pull", m_d->actionMan);
menu->addSeparator();
if (addFrameCreationActions) {
KisActionManager::safePopulateMenu(menu, "add_blank_frame", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "add_duplicate_frame", m_d->actionMan);
menu->addSeparator();
}
}
void TimelineFramesView::mousePressEvent(QMouseEvent *event)
{
QPersistentModelIndex index = indexAt(event->pos());
if (m_d->modifiersCatcher->modifierPressed("pan-zoom")) {
if (event->button() == Qt::RightButton) {
// TODO: try calculate index under mouse cursor even when
// it is outside any visible row
qreal staticPoint = index.isValid() ? index.column() : currentIndex().column();
m_d->zoomDragButton->beginZoom(event->pos(), staticPoint);
} else if (event->button() == Qt::LeftButton) {
m_d->initialDragPanPos = event->pos();
m_d->initialDragPanValue =
QPoint(horizontalScrollBar()->value(),
verticalScrollBar()->value());
}
event->accept();
} else if (event->button() == Qt::RightButton) {
int numSelectedItems = selectionModel()->selectedIndexes().size();
if (index.isValid() &&
numSelectedItems <= 1 &&
m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) {
model()->setData(index, true, TimelineFramesModel::ActiveLayerRole);
model()->setData(index, true, TimelineFramesModel::ActiveFrameRole);
setCurrentIndex(index);
if (model()->data(index, TimelineFramesModel::FrameExistsRole).toBool() ||
model()->data(index, TimelineFramesModel::SpecialKeyframeExists).toBool()) {
{
KisSignalsBlocker b(m_d->colorSelector);
QVariant colorLabel = index.data(TimelineFramesModel::FrameColorLabelIndexRole);
int labelIndex = colorLabel.isValid() ? colorLabel.toInt() : 0;
m_d->colorSelector->setCurrentIndex(labelIndex);
}
QMenu menu;
createFrameEditingMenuActions(&menu, false);
menu.addSeparator();
menu.addAction(m_d->colorSelectorAction);
menu.exec(event->globalPos());
} else {
{
KisSignalsBlocker b(m_d->colorSelector);
const int labelIndex = KisImageConfig(true).defaultFrameColorLabel();
m_d->colorSelector->setCurrentIndex(labelIndex);
}
QMenu menu;
createFrameEditingMenuActions(&menu, true);
menu.addSeparator();
menu.addAction(m_d->colorSelectorAction);
menu.exec(event->globalPos());
}
} else if (numSelectedItems > 1) {
int labelIndex = -1;
bool haveFrames = false;
Q_FOREACH(QModelIndex index, selectedIndexes()) {
haveFrames |= index.data(TimelineFramesModel::FrameExistsRole).toBool();
QVariant colorLabel = index.data(TimelineFramesModel::FrameColorLabelIndexRole);
if (colorLabel.isValid()) {
if (labelIndex == -1) {
// First label
labelIndex = colorLabel.toInt();
} else if (labelIndex != colorLabel.toInt()) {
// Mixed colors in selection
labelIndex = -1;
break;
}
}
}
if (haveFrames) {
KisSignalsBlocker b(m_d->multiframeColorSelector);
m_d->multiframeColorSelector->setCurrentIndex(labelIndex);
}
QMenu menu;
createFrameEditingMenuActions(&menu, false);
menu.addSeparator();
KisActionManager::safePopulateMenu(&menu, "mirror_frames", m_d->actionMan);
menu.addSeparator();
menu.addAction(m_d->multiframeColorSelectorAction);
menu.exec(event->globalPos());
}
} else if (event->button() == Qt::MidButton) {
QModelIndex index = model()->buddy(indexAt(event->pos()));
if (index.isValid()) {
QStyleOptionViewItem option = viewOptions();
option.rect = visualRect(index);
// The offset of the headers is needed to get the correct position inside the view.
m_d->tip.showTip(this, event->pos() + QPoint(verticalHeader()->width(), horizontalHeader()->height()), option, index);
}
event->accept();
} else {
if (index.isValid()) {
m_d->model->setLastClickedIndex(index);
}
m_d->lastPressedPosition =
QPoint(horizontalOffset(), verticalOffset()) + event->pos();
m_d->lastPressedModifier = event->modifiers();
QAbstractItemView::mousePressEvent(event);
}
}
void TimelineFramesView::mouseMoveEvent(QMouseEvent *e)
{
if (m_d->modifiersCatcher->modifierPressed("pan-zoom")) {
if (e->buttons() & Qt::RightButton) {
m_d->zoomDragButton->continueZoom(e->pos());
} else if (e->buttons() & Qt::LeftButton) {
QPoint diff = e->pos() - m_d->initialDragPanPos;
QPoint offset = QPoint(m_d->initialDragPanValue.x() - diff.x(),
m_d->initialDragPanValue.y() - diff.y());
const int height = m_d->layersHeader->defaultSectionSize();
horizontalScrollBar()->setValue(offset.x());
verticalScrollBar()->setValue(offset.y() / height);
}
e->accept();
} else if (e->buttons() == Qt::MidButton) {
QModelIndex index = model()->buddy(indexAt(e->pos()));
if (index.isValid()) {
QStyleOptionViewItem option = viewOptions();
option.rect = visualRect(index);
// The offset of the headers is needed to get the correct position inside the view.
m_d->tip.showTip(this, e->pos() + QPoint(verticalHeader()->width(), horizontalHeader()->height()), option, index);
}
e->accept();
} else {
m_d->model->setScrubState(true);
QTableView::mouseMoveEvent(e);
}
}
void TimelineFramesView::mouseReleaseEvent(QMouseEvent *e)
{
if (m_d->modifiersCatcher->modifierPressed("pan-zoom")) {
e->accept();
} else {
m_d->model->setScrubState(false);
QTableView::mouseReleaseEvent(e);
}
}
void TimelineFramesView::wheelEvent(QWheelEvent *e)
{
QModelIndex index = currentIndex();
int column= -1;
if (index.isValid()) {
column= index.column() + ((e->delta() > 0) ? 1 : -1);
}
if (column >= 0 && !m_d->dragInProgress) {
setCurrentIndex(m_d->model->index(index.row(), column));
}
}
void TimelineFramesView::slotUpdateLayersMenu()
{
QAction *action = 0;
m_d->existingLayersMenu->clear();
QVariant value = model()->headerData(0, Qt::Vertical, TimelineFramesModel::OtherLayersRole);
if (value.isValid()) {
TimelineFramesModel::OtherLayersList list = value.value();
int i = 0;
Q_FOREACH (const TimelineFramesModel::OtherLayer &l, list) {
action = m_d->existingLayersMenu->addAction(l.name);
action->setData(i++);
}
}
}
void TimelineFramesView::slotUpdateFrameActions()
{
if (!m_d->actionMan) return;
const QModelIndexList editableIndexes = calculateSelectionSpan(false, true);
const bool hasEditableFrames = !editableIndexes.isEmpty();
bool hasExistingFrames = false;
Q_FOREACH (const QModelIndex &index, editableIndexes) {
if (model()->data(index, TimelineFramesModel::FrameExistsRole).toBool()) {
hasExistingFrames = true;
break;
}
}
auto enableAction = [this] (const QString &id, bool value) {
KisAction *action = m_d->actionMan->actionByName(id);
KIS_SAFE_ASSERT_RECOVER_RETURN(action);
action->setEnabled(value);
};
enableAction("add_blank_frame", hasEditableFrames);
enableAction("add_duplicate_frame", hasEditableFrames);
enableAction("insert_keyframe_left", hasEditableFrames);
enableAction("insert_keyframe_right", hasEditableFrames);
enableAction("insert_multiple_keyframes", hasEditableFrames);
enableAction("remove_frames", hasEditableFrames && hasExistingFrames);
enableAction("remove_frames_and_pull", hasEditableFrames);
enableAction("insert_hold_frame", hasEditableFrames);
enableAction("insert_multiple_hold_frames", hasEditableFrames);
enableAction("remove_hold_frame", hasEditableFrames);
enableAction("remove_multiple_hold_frames", hasEditableFrames);
enableAction("mirror_frames", hasEditableFrames && editableIndexes.size() > 1);
enableAction("copy_frames_to_clipboard", true);
enableAction("cut_frames_to_clipboard", hasEditableFrames);
-
- enableAction("insert_opacity_keyframe", hasEditableFrames);
- enableAction("remove_opacity_keyframe", hasEditableFrames);
-
- //QClipboard *cp = QApplication::clipboard();
- //const QMimeData *data = cp->mimeData();
-
-
- //TODO: update column actions!
}
void TimelineFramesView::slotSetStartTimeToCurrentPosition()
{
m_d->model->setFullClipRangeStart(this->currentIndex().column());
}
void TimelineFramesView::slotSetEndTimeToCurrentPosition()
{
m_d->model->setFullClipRangeEnd(this->currentIndex().column());
}
void TimelineFramesView::slotUpdatePlackbackRange()
{
QSet rows;
int minColumn = 0;
int maxColumn = 0;
calculateSelectionMetrics(minColumn, maxColumn, rows);
m_d->model->setFullClipRangeStart(minColumn);
m_d->model->setFullClipRangeEnd(maxColumn);
}
void TimelineFramesView::slotLayerContextMenuRequested(const QPoint &globalPos)
{
m_d->layerEditingMenu->exec(globalPos);
}
void TimelineFramesView::slotAddNewLayer()
{
QModelIndex index = currentIndex();
const int newRow = index.isValid() ? index.row() : 0;
model()->insertRow(newRow);
}
void TimelineFramesView::slotAddExistingLayer(QAction *action)
{
QVariant value = action->data();
if (value.isValid()) {
QModelIndex index = currentIndex();
const int newRow = index.isValid() ? index.row() + 1 : 0;
m_d->model->insertOtherLayer(value.toInt(), newRow);
}
}
void TimelineFramesView::slotRemoveLayer()
{
QModelIndex index = currentIndex();
if (!index.isValid()) return;
model()->removeRow(index.row());
}
void TimelineFramesView::slotAddBlankFrame()
{
ENTER_FUNCTION();
QModelIndex index = currentIndex();
if (!index.isValid() ||
!m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) {
return;
}
m_d->model->createFrame(index);
}
void TimelineFramesView::slotAddDuplicateFrame()
{
QModelIndex index = currentIndex();
if (!index.isValid() ||
!m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) {
return;
}
m_d->model->copyFrame(index);
}
void TimelineFramesView::calculateSelectionMetrics(int &minColumn, int &maxColumn, QSet &rows) const
{
minColumn = std::numeric_limits::max();
maxColumn = std::numeric_limits::min();
Q_FOREACH (const QModelIndex &index, selectionModel()->selectedIndexes()) {
if (!m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) continue;
rows.insert(index.row());
minColumn = qMin(minColumn, index.column());
maxColumn = qMax(maxColumn, index.column());
}
}
void TimelineFramesView::insertKeyframes(int count, int timing, TimelineDirection direction, bool entireColumn)
{
QSet rows;
int minColumn = 0, maxColumn = 0;
calculateSelectionMetrics(minColumn, maxColumn, rows);
if (count <= 0) { //Negative count? Use number of selected frames.
count = qMax(1, maxColumn - minColumn + 1);
}
const int insertionColumn =
direction == TimelineDirection::RIGHT ?
maxColumn + 1 : minColumn;
if (entireColumn) {
rows.clear();
for (int i = 0; i < m_d->model->rowCount(); i++) {
if (!m_d->model->data(m_d->model->index(i, insertionColumn), TimelineFramesModel::FrameEditableRole).toBool()) continue;
rows.insert(i);
}
}
if (!rows.isEmpty()) {
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
m_d->model->insertFrames(insertionColumn, QList(rows.begin(), rows.end()), count, timing);
#else
m_d->model->insertFrames(insertionColumn, QList::fromSet(rows), count, timing);
#endif
}
}
void TimelineFramesView::insertMultipleKeyframes(bool entireColumn)
{
int count, timing;
TimelineDirection direction;
if (m_d->insertKeyframeDialog->promptUserSettings(count, timing, direction)) {
insertKeyframes(count, timing, direction, entireColumn);
}
}
QModelIndexList TimelineFramesView::calculateSelectionSpan(bool entireColumn, bool editableOnly) const
{
QModelIndexList indexes;
if (entireColumn) {
QSet rows;
int minColumn = 0;
int maxColumn = 0;
calculateSelectionMetrics(minColumn, maxColumn, rows);
rows.clear();
for (int i = 0; i < m_d->model->rowCount(); i++) {
if (editableOnly &&
!m_d->model->data(m_d->model->index(i, minColumn), TimelineFramesModel::FrameEditableRole).toBool()) continue;
for (int column = minColumn; column <= maxColumn; column++) {
indexes << m_d->model->index(i, column);
}
}
} else {
Q_FOREACH (const QModelIndex &index, selectionModel()->selectedIndexes()) {
if (!editableOnly || m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) {
indexes << index;
}
}
}
return indexes;
}
void TimelineFramesView::slotRemoveSelectedFrames(bool entireColumn, bool pull)
{
const QModelIndexList selectedIndices = calculateSelectionSpan(entireColumn);
if (!selectedIndices.isEmpty()) {
if (pull) {
m_d->model->removeFramesAndOffset(selectedIndices);
} else {
m_d->model->removeFrames(selectedIndices);
}
}
}
void TimelineFramesView::insertOrRemoveHoldFrames(int count, bool entireColumn)
{
QModelIndexList indexes;
if (!entireColumn) {
Q_FOREACH (const QModelIndex &index, selectionModel()->selectedIndexes()) {
if (m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) {
indexes << index;
}
}
} else {
const int column = selectionModel()->currentIndex().column();
for (int i = 0; i < m_d->model->rowCount(); i++) {
const QModelIndex index = m_d->model->index(i, column);
if (m_d->model->data(index, TimelineFramesModel::FrameEditableRole).toBool()) {
indexes << index;
}
}
}
if (!indexes.isEmpty()) {
// add extra columns to the end of the timeline if we are adding hold frames
// they will be truncated if we don't do this
if (count > 0) {
// Scan all the layers and find out what layer has the most keyframes
// only keep a reference of layer that has the most keyframes
int keyframesInLayerNode = 0;
Q_FOREACH (const QModelIndex &index, indexes) {
KisNodeSP layerNode = m_d->model->nodeAt(index);
KisKeyframeChannel *channel = layerNode->getKeyframeChannel(KisKeyframeChannel::Content.id());
if (!channel) continue;
if (keyframesInLayerNode < channel->allKeyframeIds().count()) {
keyframesInLayerNode = channel->allKeyframeIds().count();
}
}
m_d->model->setLastVisibleFrame(m_d->model->columnCount() + count*keyframesInLayerNode);
}
m_d->model->insertHoldFrames(indexes, count);
// bulk adding frames can add too many
// trim timeline to clean up extra frames that might have been added
slotUpdateInfiniteFramesCount();
}
}
void TimelineFramesView::insertOrRemoveMultipleHoldFrames(bool insertion, bool entireColumn)
{
bool ok = false;
const int count = QInputDialog::getInt(this,
i18nc("@title:window", "Insert or Remove Hold Frames"),
i18nc("@label:spinbox", "Enter number of frames"),
insertion ?
m_d->insertKeyframeDialog->defaultTimingOfAddedFrames() :
m_d->insertKeyframeDialog->defaultNumberOfHoldFramesToRemove(),
1, 10000, 1, &ok);
if (ok) {
if (insertion) {
m_d->insertKeyframeDialog->setDefaultTimingOfAddedFrames(count);
insertOrRemoveHoldFrames(count, entireColumn);
} else {
m_d->insertKeyframeDialog->setDefaultNumberOfHoldFramesToRemove(count);
insertOrRemoveHoldFrames(-count, entireColumn);
}
}
}
void TimelineFramesView::slotMirrorFrames(bool entireColumn)
{
const QModelIndexList indexes = calculateSelectionSpan(entireColumn);
if (!indexes.isEmpty()) {
m_d->model->mirrorFrames(indexes);
}
}
void TimelineFramesView::cutCopyImpl(bool entireColumn, bool copy)
{
const QModelIndexList selectedIndices = calculateSelectionSpan(entireColumn, !copy);
if (selectedIndices.isEmpty()) return;
int minColumn = std::numeric_limits::max();
int minRow = std::numeric_limits::max();
Q_FOREACH (const QModelIndex &index, selectedIndices) {
minRow = qMin(minRow, index.row());
minColumn = qMin(minColumn, index.column());
}
const QModelIndex baseIndex = m_d->model->index(minRow, minColumn);
QMimeData *data = m_d->model->mimeDataExtended(selectedIndices,
baseIndex,
copy ?
TimelineFramesModel::CopyFramesPolicy :
TimelineFramesModel::MoveFramesPolicy);
if (data) {
QClipboard *cb = QApplication::clipboard();
cb->setMimeData(data);
}
}
void TimelineFramesView::slotPasteFrames(bool entireColumn)
{
const QModelIndex currentIndex =
!entireColumn ? this->currentIndex() : m_d->model->index(0, this->currentIndex().column());
if (!currentIndex.isValid()) return;
QClipboard *cb = QApplication::clipboard();
const QMimeData *data = cb->mimeData();
if (data && data->hasFormat("application/x-krita-frame")) {
bool dataMoved = false;
bool result = m_d->model->dropMimeDataExtended(data, Qt::MoveAction, currentIndex, &dataMoved);
if (result && dataMoved) {
cb->clear();
}
}
}
bool TimelineFramesView::viewportEvent(QEvent *event)
{
if (event->type() == QEvent::ToolTip && model()) {
QHelpEvent *he = static_cast(event);
QModelIndex index = model()->buddy(indexAt(he->pos()));
if (index.isValid()) {
QStyleOptionViewItem option = viewOptions();
option.rect = visualRect(index);
// The offset of the headers is needed to get the correct position inside the view.
m_d->tip.showTip(this, he->pos() + QPoint(verticalHeader()->width(), horizontalHeader()->height()), option, index);
return true;
}
}
return QTableView::viewportEvent(event);
}