Commit ddfcaa0f authored by Chris Suran's avatar Chris Suran Committed by Nate Graham
Browse files

Add Zoom scroll wheel option

Summary:
Adding a Zoom option for scrolling in the configuration

BUG: 254511
FIXED-IN: 18.12.0

Test Plan: Test scrolling in image and folder view for each configuration selection.

Reviewers: #gwenview, ngraham

Reviewed By: ngraham

Subscribers: sourabhboss, muhlenpfordt, ngraham

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D15809
parent bf9ed0fe
......@@ -76,6 +76,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)
mWheelBehaviorGroup->setObjectName(QLatin1String("kcfg_MouseWheelBehavior"));
mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelScrollRadioButton, int(MouseWheelBehavior::Scroll));
mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelBrowseRadioButton, int(MouseWheelBehavior::Browse));
mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelZoomRadioButton, int(MouseWheelBehavior::Zoom));
mAnimationMethodGroup = new InvisibleButtonGroup(widget);
mAnimationMethodGroup->setObjectName(QLatin1String("kcfg_AnimationMethod"));
......
......@@ -211,6 +211,30 @@
</layout>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QRadioButton" name="mouseWheelZoomRadioButton">
<property name="text">
<string comment="@option:radio action on mouse wheel">Zoom</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="7" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -226,7 +250,7 @@
</property>
</spacer>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Zoom mode:</string>
......@@ -239,7 +263,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QRadioButton" name="autofitZoomModeRadioButton">
......@@ -266,7 +290,7 @@
</item>
</layout>
</item>
<item row="8" column="1">
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QRadioButton" name="keepSameZoomModeRadioButton">
......@@ -290,7 +314,7 @@
</item>
</layout>
</item>
<item row="9" column="1">
<item row="10" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QRadioButton" name="individualZoomModeRadioButton">
......@@ -314,7 +338,7 @@
</item>
</layout>
</item>
<item row="10" column="1">
<item row="11" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -330,7 +354,7 @@
</property>
</spacer>
</item>
<item row="11" column="1">
<item row="12" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QCheckBox" name="kcfg_EnlargeSmallerImages">
......@@ -354,7 +378,7 @@
</item>
</layout>
</item>
<item row="12" column="1">
<item row="13" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -370,7 +394,7 @@
</property>
</spacer>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Animations:</string>
......@@ -383,7 +407,7 @@
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QRadioButton" name="glAnimationRadioButton">
......@@ -410,7 +434,7 @@
</item>
</layout>
</item>
<item row="14" column="1">
<item row="15" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QRadioButton" name="softwareAnimationRadioButton">
......@@ -434,7 +458,7 @@
</item>
</layout>
</item>
<item row="15" column="1">
<item row="16" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QRadioButton" name="noAnimationRadioButton">
......@@ -458,7 +482,7 @@
</item>
</layout>
</item>
<item row="16" column="1">
<item row="17" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -474,14 +498,14 @@
</property>
</spacer>
</item>
<item row="17" column="0">
<item row="18" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;b&gt;Thumbnail Bar&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="18" column="1">
<item row="19" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -497,7 +521,7 @@
</property>
</spacer>
</item>
<item row="19" column="0">
<item row="20" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Orientation:</string>
......@@ -510,7 +534,7 @@
</property>
</widget>
</item>
<item row="19" column="1">
<item row="20" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QRadioButton" name="horizontalRadioButton">
......@@ -534,7 +558,7 @@
</item>
</layout>
</item>
<item row="20" column="1">
<item row="21" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QRadioButton" name="verticalRadioButton">
......@@ -558,7 +582,7 @@
</item>
</layout>
</item>
<item row="21" column="0">
<item row="22" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Row count:</string>
......@@ -571,7 +595,7 @@
</property>
</widget>
</item>
<item row="21" column="1">
<item row="22" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QSpinBox" name="kcfg_ThumbnailBarRowCount">
......@@ -598,7 +622,7 @@
</item>
</layout>
</item>
<item row="22" column="1">
<item row="23" column="1">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -631,6 +655,7 @@
<tabstop>kcfg_AlphaBackgroundColor</tabstop>
<tabstop>mouseWheelScrollRadioButton</tabstop>
<tabstop>mouseWheelBrowseRadioButton</tabstop>
<tabstop>mouseWheelZoomRadioButton</tabstop>
<tabstop>kcfg_EnlargeSmallerImages</tabstop>
<tabstop>glAnimationRadioButton</tabstop>
<tabstop>softwareAnimationRadioButton</tabstop>
......
......@@ -732,17 +732,21 @@ void DocumentView::mousePressEvent(QGraphicsSceneMouseEvent* event)
void DocumentView::wheelEvent(QGraphicsSceneWheelEvent* event)
{
if (d->mAdapter->canZoom() && event->modifiers() & Qt::ControlModifier) {
d->controlWheelAccumulatedDelta += event->delta();
// Ctrl + wheel => zoom in or out
if (d->controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep) {
zoomIn(event->pos());
d->controlWheelAccumulatedDelta = 0;
} else if (d->controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep) {
zoomOut(event->pos());
d->controlWheelAccumulatedDelta = 0;
if (d->mAdapter->canZoom()) {
if ((event->modifiers() & Qt::ControlModifier) ||
(GwenviewConfig::mouseWheelBehavior() == MouseWheelBehavior::Zoom
&& event->modifiers() == Qt::NoModifier)) {
d->controlWheelAccumulatedDelta += event->delta();
// Ctrl + wheel => zoom in or out
if (d->controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep) {
zoomIn(event->pos());
d->controlWheelAccumulatedDelta = 0;
} else if (d->controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep) {
zoomOut(event->pos());
d->controlWheelAccumulatedDelta = 0;
}
return;
}
return;
}
if (GwenviewConfig::mouseWheelBehavior() == MouseWheelBehavior::Browse
&& event->modifiers() == Qt::NoModifier) {
......
......@@ -136,6 +136,7 @@
<choices name="Gwenview::MouseWheelBehavior::Enum">
<choice name="MouseWheelBehavior::Scroll"/>
<choice name="MouseWheelBehavior::Browse"/>
<choice name="MouseWheelBehavior::Zoom"/>
</choices>
<default>MouseWheelBehavior::Scroll</default>
</entry>
......
......@@ -34,7 +34,8 @@ namespace MouseWheelBehavior
{
enum Enum {
Scroll,
Browse
Browse,
Zoom
};
} // namespace MouseWheelBehavior
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment