Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
b753b3cf
Commit
b753b3cf
authored
Dec 04, 2016
by
Jean-Baptiste Mardelle
Browse files
Ctrl+Mouse Wheel now zooms on mouse position
BUG: 369198
parent
12d1eb7c
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/mainwindow.cpp
View file @
b753b3cf
...
...
@@ -1927,8 +1927,8 @@ void MainWindow::connectDocument()
connect
(
trackView
->
projectView
(),
SIGNAL
(
transitionItemSelected
(
Transition
*
,
int
,
QPoint
,
bool
)),
m_effectStack
,
SLOT
(
slotTransitionItemSelected
(
Transition
*
,
int
,
QPoint
,
bool
)),
Qt
::
DirectConnection
);
connect
(
trackView
->
projectView
(),
SIGNAL
(
transitionItemSelected
(
Transition
*
,
int
,
QPoint
,
bool
)),
this
,
SLOT
(
slotActivateTransitionView
(
Transition
*
)));
connect
(
trackView
->
projectView
(),
SIGNAL
(
zoomIn
()),
this
,
SLOT
(
slotZoomIn
()));
connect
(
trackView
->
projectView
(),
SIGNAL
(
zoomOut
()),
this
,
SLOT
(
slotZoomOut
()));
connect
(
trackView
->
projectView
(),
SIGNAL
(
zoomIn
(
bool
)),
this
,
SLOT
(
slotZoomIn
(
bool
)));
connect
(
trackView
->
projectView
(),
SIGNAL
(
zoomOut
(
bool
)),
this
,
SLOT
(
slotZoomOut
(
bool
)));
connect
(
trackView
,
SIGNAL
(
setZoom
(
int
)),
this
,
SLOT
(
slotSetZoom
(
int
)));
connect
(
trackView
,
SIGNAL
(
displayMessage
(
QString
,
MessageType
)),
m_messageLabel
,
SLOT
(
setMessage
(
QString
,
MessageType
)));
connect
(
trackView
->
projectView
(),
SIGNAL
(
displayMessage
(
QString
,
MessageType
)),
m_messageLabel
,
SLOT
(
setMessage
(
QString
,
MessageType
)));
...
...
@@ -2640,15 +2640,15 @@ void MainWindow::slotAddVideoEffect(QAction *result)
}
void
MainWindow
::
slotZoomIn
()
void
MainWindow
::
slotZoomIn
(
bool
zoomOnMouse
)
{
m_zoomSlider
->
setValue
(
m_zoomSlider
->
value
()
-
1
);
slotSetZoom
(
m_zoomSlider
->
value
()
-
1
,
zoomOnMouse
);
slotShowZoomSliderToolTip
();
}
void
MainWindow
::
slotZoomOut
()
void
MainWindow
::
slotZoomOut
(
bool
zoomOnMouse
)
{
m_zoomSlider
->
setValue
(
m_zoomSlider
->
value
()
+
1
);
slotSetZoom
(
m_zoomSlider
->
value
()
+
1
,
zoomOnMouse
);
slotShowZoomSliderToolTip
();
}
...
...
@@ -2661,13 +2661,12 @@ void MainWindow::slotFitZoom()
}
}
void
MainWindow
::
slotSetZoom
(
int
value
)
void
MainWindow
::
slotSetZoom
(
int
value
,
bool
zoomOnMouse
)
{
value
=
qMax
(
m_zoomSlider
->
minimum
(),
value
);
value
=
qMin
(
m_zoomSlider
->
maximum
(),
value
);
value
=
qBound
(
m_zoomSlider
->
minimum
(),
value
,
m_zoomSlider
->
maximum
());
if
(
pCore
->
projectManager
()
->
currentTimeline
())
{
pCore
->
projectManager
()
->
currentTimeline
()
->
slotChangeZoom
(
value
);
pCore
->
projectManager
()
->
currentTimeline
()
->
slotChangeZoom
(
value
,
-
1
,
zoomOnMouse
);
}
m_zoomOut
->
setEnabled
(
value
<
m_zoomSlider
->
maximum
());
...
...
src/mainwindow.h
View file @
b753b3cf
...
...
@@ -298,11 +298,11 @@ private slots:
/** @brief Sets the timeline zoom slider to @param value.
*
* Also disables zoomIn and zoomOut actions if they cannot be used at the moment. */
void
slotSetZoom
(
int
value
);
void
slotSetZoom
(
int
value
,
bool
zoomOnMouse
=
false
);
/** @brief Decreases the timeline zoom level by 1. */
void
slotZoomIn
();
void
slotZoomIn
(
bool
zoomOnMouse
=
false
);
/** @brief Increases the timeline zoom level by 1. */
void
slotZoomOut
();
void
slotZoomOut
(
bool
zoomOnMouse
=
false
);
/** @brief Makes the timeline zoom level fit the timeline content. */
void
slotFitZoom
();
/** @brief Updates the zoom slider tooltip to fit @param zoomlevel. */
...
...
src/timeline/customtrackview.cpp
View file @
b753b3cf
...
...
@@ -195,7 +195,7 @@ void CustomTrackView::initTools()
m_toolManagers
.
insert
(
AbstractToolManager
::
TrimType
,
trim
);
m_toolManagers
.
insert
(
AbstractToolManager
::
SpacerType
,
new
SpacerManager
(
this
,
m_commandStack
));
m_toolManagers
.
insert
(
AbstractToolManager
::
ResizeType
,
new
ResizeManager
(
this
,
m_commandStack
));
AbstractToolManager
*
razorManager
=
new
RazorManager
(
this
,
m_commandStack
);
m_toolManagers
.
insert
(
AbstractToolManager
::
RazorType
,
razorManager
);
connect
(
horizontalScrollBar
(),
SIGNAL
(
valueChanged
(
int
)),
razorManager
,
SLOT
(
updateTimelineItems
()));
...
...
@@ -410,8 +410,8 @@ void CustomTrackView::wheelEvent(QWheelEvent * e)
{
if
(
e
->
modifiers
()
==
Qt
::
ControlModifier
)
{
if
(
m_moveOpMode
==
None
||
m_moveOpMode
==
WaitingForConfirm
||
m_moveOpMode
==
ZoomTimeline
)
{
if
(
e
->
delta
()
>
0
)
emit
zoomIn
();
else
emit
zoomOut
();
if
(
e
->
delta
()
>
0
)
emit
zoomIn
(
true
);
else
emit
zoomOut
(
true
);
}
}
else
if
(
e
->
modifiers
()
==
Qt
::
AltModifier
)
{
if
(
m_moveOpMode
==
None
||
m_moveOpMode
==
WaitingForConfirm
||
m_moveOpMode
==
ZoomTimeline
)
{
...
...
@@ -5854,10 +5854,11 @@ void CustomTrackView::setTool(ProjectTool tool)
m_currentToolManager
->
initTool
(
m_tracksHeight
*
m_scene
->
scale
().
y
());
}
void
CustomTrackView
::
setScale
(
double
scaleFactor
,
double
verticalScale
)
void
CustomTrackView
::
setScale
(
double
scaleFactor
,
double
verticalScale
,
bool
zoomOnMouse
)
{
QMatrix
newmatrix
;
int
lastMousePos
=
getMousePos
();
newmatrix
=
newmatrix
.
scale
(
scaleFactor
,
verticalScale
);
m_scene
->
isZooming
=
true
;
m_scene
->
setScale
(
scaleFactor
,
verticalScale
);
...
...
@@ -5900,7 +5901,14 @@ void CustomTrackView::setScale(double scaleFactor, double verticalScale)
setSceneRect
(
0
,
0
,
(
m_projectDuration
+
300
),
sceneRect
().
height
());
}
double
verticalPos
=
mapToScene
(
QPoint
(
0
,
viewport
()
->
height
()
/
2
)).
y
();
centerOn
(
QPointF
(
cursorPos
(),
verticalPos
));
if
(
zoomOnMouse
)
{
// Zoom on mouse position
centerOn
(
QPointF
(
lastMousePos
,
verticalPos
));
int
diff
=
scaleFactor
*
(
getMousePos
()
-
lastMousePos
);
horizontalScrollBar
()
->
setValue
(
horizontalScrollBar
()
->
value
()
-
diff
);
}
else
{
centerOn
(
QPointF
(
cursorPos
(),
verticalPos
));
}
m_currentToolManager
->
updateTimelineItems
();
m_scene
->
isZooming
=
false
;
}
...
...
src/timeline/customtrackview.h
View file @
b753b3cf
...
...
@@ -79,7 +79,7 @@ public:
void
deleteClip
(
ItemInfo
info
,
bool
refresh
=
true
);
void
addMarker
(
const
QString
&
id
,
const
CommentedTime
&
marker
);
void
addData
(
const
QString
&
id
,
const
QString
&
key
,
const
QString
&
data
);
void
setScale
(
double
scaleFactor
,
double
verticalScale
);
void
setScale
(
double
scaleFactor
,
double
verticalScale
,
bool
zoomOnMouse
=
false
);
void
deleteClip
(
const
QString
&
clipId
,
QUndoCommand
*
deleteCommand
);
/** @brief An effect was dropped on @param clip */
void
slotDropEffect
(
ClipItem
*
clip
,
QDomElement
effect
,
GenTime
pos
,
int
track
);
...
...
@@ -586,8 +586,8 @@ private slots:
signals:
void
cursorMoved
(
int
,
int
);
void
zoomIn
();
void
zoomOut
();
void
zoomIn
(
bool
zoomOnMouse
);
void
zoomOut
(
bool
zoomOnMouse
);
void
mousePosition
(
int
);
/** @brief A clip was selected in timeline, update the effect stack
* @param clip The clip
...
...
src/timeline/timeline.cpp
View file @
b753b3cf
...
...
@@ -568,7 +568,7 @@ void Timeline::moveCursorPos(int pos)
m_trackview
->
setCursorPos
(
pos
);
}
void
Timeline
::
slotChangeZoom
(
int
horizontal
,
int
vertical
)
void
Timeline
::
slotChangeZoom
(
int
horizontal
,
int
vertical
,
bool
zoomOnMouse
)
{
m_ruler
->
setPixelPerMark
(
horizontal
);
m_scale
=
(
double
)
m_trackview
->
getFrameWidth
()
/
m_ruler
->
comboScale
[
horizontal
];
...
...
@@ -576,7 +576,7 @@ void Timeline::slotChangeZoom(int horizontal, int vertical)
if
(
vertical
==
-
1
)
{
// user called zoom
m_doc
->
setZoom
(
horizontal
,
m_verticalZoom
);
m_trackview
->
setScale
(
m_scale
,
m_scene
->
scale
().
y
());
m_trackview
->
setScale
(
m_scale
,
m_scene
->
scale
().
y
()
,
zoomOnMouse
);
}
else
{
m_verticalZoom
=
vertical
;
if
(
m_verticalZoom
==
0
)
...
...
src/timeline/timeline.h
View file @
b753b3cf
...
...
@@ -191,7 +191,7 @@ public:
public
slots
:
void
slotDeleteClip
(
const
QString
&
clipId
,
QUndoCommand
*
deleteCommand
);
void
slotChangeZoom
(
int
horizontal
,
int
vertical
=
-
1
);
void
slotChangeZoom
(
int
horizontal
,
int
vertical
=
-
1
,
bool
zoomOnMouse
=
false
);
void
setDuration
(
int
dur
);
void
slotSetZone
(
const
QPoint
&
p
,
bool
updateDocumentProperties
=
true
);
/** @brief Save a snapshot image of current timeline view */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment