diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp
index c6a80a87f..2a5b7f41b 100644
--- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp
+++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp
@@ -45,6 +45,10 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
m_labelLangChanged(false)
{
ui->setupUi(this);
+
+ ui->tabWidget->setCurrentIndex(0);
+
+ // Tab General
ui->autoSaveCheck->setChecked(qApp->ValentinaSettings()->GetAutosaveState());
InitLanguages(ui->langCombo);
@@ -107,11 +111,34 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
settings->SetConfirmFormatRewriting(true);
});
- ui->checkBoxFreeCurve->setChecked(qApp->ValentinaSettings()->IsFreeCurveMode());
- ui->checkBoxZoomFitBestCurrentPP->setChecked(qApp->ValentinaSettings()->IsDoubleClickZoomFitBestCurrentPP());
+ VSettings *settings = qApp->ValentinaSettings();
+
+ ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode());
+ ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP());
//----------------------- Toolbar
- ui->toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle());
+ ui->toolBarStyleCheck->setChecked(settings->GetToolBarStyle());
+
+ // Tab Scrolling
+ ui->spinBoxDuration->setMinimum(VSettings::scrollingDurationMin);
+ ui->spinBoxDuration->setMaximum(VSettings::scrollingDurationMax);
+ ui->spinBoxDuration->setValue(settings->GetScrollingDuration());
+
+ ui->spinBoxUpdateInterval->setMinimum(VSettings::scrollingUpdateIntervalMin);
+ ui->spinBoxUpdateInterval->setMaximum(VSettings::scrollingUpdateIntervalMin);
+ ui->spinBoxUpdateInterval->setValue(settings->GetScrollingUpdateInterval());
+
+ ui->doubleSpinBoxSensor->setMinimum(VSettings::sensorMouseScaleMin);
+ ui->doubleSpinBoxSensor->setMaximum(VSettings::sensorMouseScaleMax);
+ ui->doubleSpinBoxSensor->setValue(settings->GetSensorMouseScale());
+
+ ui->doubleSpinBoxWheel->setMinimum(VSettings::wheelMouseScaleMin);
+ ui->doubleSpinBoxWheel->setMaximum(VSettings::wheelMouseScaleMax);
+ ui->doubleSpinBoxWheel->setValue(settings->GetWheelMouseScale());
+
+ ui->doubleSpinBoxAcceleration->setMinimum(VSettings::scrollingAccelerationMin);
+ ui->doubleSpinBoxAcceleration->setMaximum(VSettings::scrollingAccelerationMax);
+ ui->doubleSpinBoxAcceleration->setValue(settings->GetScrollingAcceleration());
}
//---------------------------------------------------------------------------------------------------------------------
@@ -123,6 +150,7 @@ PreferencesConfigurationPage::~PreferencesConfigurationPage()
//---------------------------------------------------------------------------------------------------------------------
QStringList PreferencesConfigurationPage::Apply()
{
+ // Tab General
QStringList preferences;
VSettings *settings = qApp->ValentinaSettings();
settings->SetAutosaveState(ui->autoSaveCheck->isChecked());
@@ -163,6 +191,14 @@ QStringList PreferencesConfigurationPage::Apply()
settings->SetLabelLanguage(locale);
m_labelLangChanged = false;
}
+
+ // Tab Scrolling
+ settings->SetScrollingDuration(ui->spinBoxDuration->value());
+ settings->SetScrollingUpdateInterval(ui->spinBoxUpdateInterval->value());
+ settings->SetSensorMouseScale(ui->doubleSpinBoxSensor->value());
+ settings->SetWheelMouseScale(ui->doubleSpinBoxWheel->value());
+ settings->SetScrollingAcceleration(ui->doubleSpinBoxAcceleration->value());
+
return preferences;
}
diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui
index 2845e97fe..6d4b736da 100644
--- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui
+++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui
@@ -6,245 +6,442 @@
0
0
- 501
- 611
+ 516
+ 691
Configuration
-
+
-
-
-
- Save
+
+
+ 0
-
-
-
-
-
- Auto-save modified pattern
-
-
- true
-
-
-
- -
-
-
- Interval:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- min
-
-
- 1
-
-
- 60
-
-
-
-
+
+
+ General
+
+
+ -
+
+
+ Save
+
+
+
-
+
+
+ Auto-save modified pattern
+
+
+ true
+
+
+
+ -
+
+
+ Interval:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ min
+
+
+ 1
+
+
+ 60
+
+
+
+
+
+
+ -
+
+
+ Language
+
+
+
+ QFormLayout::ExpandingFieldsGrow
+
+
-
+
+
+ GUI language:
+
+
+
+ -
+
+
+ -
+
+
+ Decimal separator parts:
+
+
+
+ -
+
+
+ < With OS options >
+
+
+ true
+
+
+
+ -
+
+
+ Default unit:
+
+
+
+ -
+
+
+ Label language:
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+ Pattern making system
+
+
+
+ QFormLayout::ExpandingFieldsGrow
+
+
-
+
+
+ Pattern making system:
+
+
+
+ -
+
+
+ -
+
+
+ Author:
+
+
+
+ -
+
+
+ author
+
+
+
+ -
+
+
+ Book:
+
+
+
+ -
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Pattern editing
+
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Reset warnings
+
+
+
+ -
+
+
+ Update a pattern only after a curve release
+
+
+ Free curve mode
+
+
+ true
+
+
+
+ -
+
+
+ Double click calls Zoom fit best for current pattern piece
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Toolbar
+
+
+
-
+
+
+ The text appears under the icon (recommended for beginners).
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ Scrolling
+
+
+ -
+
+
+ Animation
+
+
+
+ QFormLayout::ExpandingFieldsGrow
+
+
-
+
+
+ Duration:
+
+
+
+ -
+
+
+ Scrolling animation duration
+
+
+ ms
+
+
+ 100
+
+
+ 1000
+
+
+ 300
+
+
+
+ -
+
+
+ Update interval:
+
+
+
+ -
+
+
+ Time in milliseconds between each animation update
+
+
+ ms
+
+
+ 10
+
+
+ 100
+
+
+ 30
+
+
+
+
+
+
+ -
+
+
+ Mouse scale
+
+
+
+ QFormLayout::ExpandingFieldsGrow
+
+
-
+
+
+ Sensor:
+
+
+
+ -
+
+
+ Scale scrolling sensitivity for mouse with sensor
+
+
+ 1.000000000000000
+
+
+ 10.000000000000000
+
+
+ 0.100000000000000
+
+
+ 2.000000000000000
+
+
+
+ -
+
+
+ Wheel:
+
+
+
+ -
+
+
+ Scale scrolling sensitivity for mouse with wheel
+
+
+ 1.000000000000000
+
+
+ 100.000000000000000
+
+
+ 0.100000000000000
+
+
+ 45.000000000000000
+
+
+
+
+
+
+ -
+
+
+ Scrolling
+
+
+
+ QFormLayout::ExpandingFieldsGrow
+
+
-
+
+
+ Acceleration:
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+ 10.000000000000000
+
+
+ 0.100000000000000
+
+
+ 1.300000000000000
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
- -
-
-
- Language
-
-
-
- QFormLayout::ExpandingFieldsGrow
-
-
-
-
-
- GUI language:
-
-
-
- -
-
-
- -
-
-
- Decimal separator parts:
-
-
-
- -
-
-
- < With OS options >
-
-
- true
-
-
-
- -
-
-
- Default unit:
-
-
-
- -
-
-
- Label language:
-
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
- Pattern making system
-
-
-
- QFormLayout::ExpandingFieldsGrow
-
-
-
-
-
- Pattern making system:
-
-
-
- -
-
-
- -
-
-
- Author:
-
-
-
- -
-
-
- author
-
-
-
- -
-
-
- Book:
-
-
-
- -
-
-
- true
-
-
-
-
-
-
- -
-
-
- Pattern editing
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Reset warnings
-
-
-
- -
-
-
- Update a pattern only after a curve release
-
-
- Free curve mode
-
-
- true
-
-
-
- -
-
-
- Double click calls Zoom fit best for current pattern piece
-
-
- true
-
-
-
-
-
-
- -
-
-
- Toolbar
-
-
-
-
-
-
- The text appears under the icon (recommended for beginners).
-
-
- true
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp
index 1bffa4ea2..b9bfdcec0 100644
--- a/src/app/valentina/mainwindow.cpp
+++ b/src/app/valentina/mainwindow.cpp
@@ -4739,6 +4739,8 @@ void MainWindow::Preferences()
&VToolOptionsPropertyBrowser::RefreshOptions);
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles);
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, [this](){emit doc->FullUpdateFromFile();});
+ connect(dlg.data(), &DialogPreferences::UpdateProperties, ui->view,
+ &VMainGraphicsView::ResetScrollingAnimation);
QGuiApplication::restoreOverrideCursor();
if (guard->exec() == QDialog::Accepted)
diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp
index eef22261e..04cadabb8 100644
--- a/src/libs/vmisc/vsettings.cpp
+++ b/src/libs/vmisc/vsettings.cpp
@@ -46,6 +46,26 @@
Q_DECLARE_METATYPE(QMarginsF)
+const int VSettings::defaultScrollingDuration = 300;
+const int VSettings::scrollingDurationMin = 100;
+const int VSettings::scrollingDurationMax = 1000;
+
+const int VSettings::defaultScrollingUpdateInterval = 30;
+const int VSettings::scrollingUpdateIntervalMin = 10;
+const int VSettings::scrollingUpdateIntervalMax = 100;
+
+const qreal VSettings::defaultSensorMouseScale = 2.0;
+const qreal VSettings::sensorMouseScaleMin = 1.0;
+const qreal VSettings::sensorMouseScaleMax = 10.0;
+
+const qreal VSettings::defaultWheelMouseScale = 45.0;
+const qreal VSettings::wheelMouseScaleMin = 1.0;
+const qreal VSettings::wheelMouseScaleMax = 100.0;
+
+const qreal VSettings::defaultScrollingAcceleration = 1.3;
+const qreal VSettings::scrollingAccelerationMin = 1.0;
+const qreal VSettings::scrollingAccelerationMax = 10.0;
+
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage,
@@ -79,6 +99,19 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String(
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation")))
+
+Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration")))
+Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval")))
+Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, (QLatin1String("scrolling/sensorMouseScale")))
+Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale")))
+Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration")))
+
+// Reading settings file is very expensive, cache values to speed up getting a value
+int scrollingDurationCached = -1;
+int scrollingUpdateIntervalCached = -1;
+qreal scrollingSensorMouseScaleCached = -1;
+qreal scrollingWheelMouseScaleCached = -1;
+qreal scrollingAccelerationCached = -1;
}
//---------------------------------------------------------------------------------------------------------------------
@@ -638,3 +671,85 @@ void VSettings::SetTiledPDFOrientation(PageOrientation value)
setValue(*settingTiledPDFOrientation, static_cast (value));
}
+//---------------------------------------------------------------------------------------------------------------------
+int VSettings::GetScrollingDuration() const
+{
+ return GetCachedValue(scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration,
+ scrollingDurationMin, scrollingDurationMax);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VSettings::SetScrollingDuration(int duration)
+{
+ scrollingDurationCached = qBound(scrollingDurationMin, duration, scrollingDurationMax);
+ setValue(*settingScrollingDuration, scrollingDurationCached);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+int VSettings::GetScrollingUpdateInterval() const
+{
+ return GetCachedValue(scrollingUpdateIntervalCached, *settingScrollingUpdateInterval,
+ defaultScrollingUpdateInterval, scrollingUpdateIntervalMin, scrollingUpdateIntervalMax);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VSettings::SetScrollingUpdateInterval(int updateInterval)
+{
+ scrollingUpdateIntervalCached = qBound(scrollingUpdateIntervalMin, updateInterval, scrollingUpdateIntervalMax);
+ setValue(*settingScrollingUpdateInterval, scrollingUpdateIntervalCached);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+qreal VSettings::GetSensorMouseScale() const
+{
+ return GetCachedValue(scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale, defaultSensorMouseScale,
+ sensorMouseScaleMin, sensorMouseScaleMax);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VSettings::SetSensorMouseScale(qreal scale)
+{
+ scrollingSensorMouseScaleCached = qBound(sensorMouseScaleMin, scale, sensorMouseScaleMax);
+ setValue(*settingScrollingSensorMouseScale, scrollingSensorMouseScaleCached);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+qreal VSettings::GetWheelMouseScale() const
+{
+ return GetCachedValue(scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale, defaultWheelMouseScale,
+ wheelMouseScaleMin, wheelMouseScaleMax);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VSettings::SetWheelMouseScale(qreal scale)
+{
+ scrollingWheelMouseScaleCached = qBound(wheelMouseScaleMin, scale, wheelMouseScaleMax);
+ setValue(*settingScrollingWheelMouseScale, scrollingWheelMouseScaleCached);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+qreal VSettings::GetScrollingAcceleration() const
+{
+ return GetCachedValue(scrollingAccelerationCached, *settingScrollingAcceleration, defaultScrollingAcceleration,
+ scrollingAccelerationMin, scrollingAccelerationMax);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VSettings::SetScrollingAcceleration(qreal acceleration)
+{
+ scrollingAccelerationCached = qBound(scrollingAccelerationMin, acceleration, scrollingAccelerationMax);
+ setValue(*settingScrollingAcceleration, scrollingAccelerationCached);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+template
+T VSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const
+{
+ if (cache < 0)
+ {
+ const QVariant val = value(setting, defValue);
+ cache = val.canConvert() ? qBound(valueMin, val.value(), valueMax) : defValue;
+ }
+
+ return cache;
+}
diff --git a/src/libs/vmisc/vsettings.h b/src/libs/vmisc/vsettings.h
index f77a0e56f..3894565db 100644
--- a/src/libs/vmisc/vsettings.h
+++ b/src/libs/vmisc/vsettings.h
@@ -148,8 +148,41 @@ public:
PageOrientation GetTiledPDFOrientation() const;
void SetTiledPDFOrientation(PageOrientation value);
+ static const int defaultScrollingDuration;
+ static const int scrollingDurationMin;
+ static const int scrollingDurationMax;
+ int GetScrollingDuration() const;
+ void SetScrollingDuration(int duration);
+
+ static const int defaultScrollingUpdateInterval;
+ static const int scrollingUpdateIntervalMin;
+ static const int scrollingUpdateIntervalMax;
+ int GetScrollingUpdateInterval() const;
+ void SetScrollingUpdateInterval(int updateInterval);
+
+ static const qreal defaultSensorMouseScale;
+ static const qreal sensorMouseScaleMin;
+ static const qreal sensorMouseScaleMax;
+ qreal GetSensorMouseScale() const;
+ void SetSensorMouseScale(qreal scale);
+
+ static const qreal defaultWheelMouseScale;
+ static const qreal wheelMouseScaleMin;
+ static const qreal wheelMouseScaleMax;
+ qreal GetWheelMouseScale() const;
+ void SetWheelMouseScale(qreal scale);
+
+ static const qreal defaultScrollingAcceleration;
+ static const qreal scrollingAccelerationMin;
+ static const qreal scrollingAccelerationMax;
+ qreal GetScrollingAcceleration() const;
+ void SetScrollingAcceleration(qreal acceleration);
+
private:
Q_DISABLE_COPY(VSettings)
+
+ template
+ T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const;
};
#endif // VSETTINGS_H
diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp
index 231de5c70..09ff75522 100644
--- a/src/libs/vwidgets/vmaingraphicsview.cpp
+++ b/src/libs/vwidgets/vmaingraphicsview.cpp
@@ -63,9 +63,6 @@
#include "../vmisc/vsettings.h"
#include "vabstractmainwindow.h"
-const int GraphicsViewZoom::duration = 350;
-const int GraphicsViewZoom::updateInterval = 30;
-
const qreal maxSceneSize = ((20.0 * 1000.0) / 25.4) * PrintDPI; // 20 meters in pixels
namespace
@@ -77,15 +74,16 @@ qreal ScrollingSteps(QWheelEvent* wheel_event)
const QPoint numPixels = wheel_event->pixelDelta();
const QPoint numDegrees = wheel_event->angleDelta() / 8;
qreal numSteps = 0;
+ VSettings *settings = qobject_cast(qApp->Settings());
if (not numPixels.isNull())
{
- const qreal mouseScale = 2.;
+ const qreal mouseScale = settings->GetSensorMouseScale();
numSteps = (wheel_event->orientation() == Qt::Vertical ? numPixels.y() : numPixels.x()) / mouseScale;
}
else if (not numDegrees.isNull())
{
- const qreal mouseScale = 45.;
+ const qreal mouseScale = settings->GetWheelMouseScale();
numSteps = (wheel_event->orientation() == Qt::Vertical ? numDegrees.y() : numDegrees.x()) / 15. * mouseScale;
}
@@ -111,7 +109,7 @@ qreal PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event)
scheduledScrollings += numSteps;
}
- scheduledScrollings *= 1.3;
+ scheduledScrollings *= qobject_cast(qApp->Settings())->GetScrollingAcceleration();
return scheduledScrollings;
}
@@ -123,24 +121,18 @@ GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
_view(view),
_modifiers(Qt::ControlModifier),
_zoom_factor_base(1.0015),
- target_scene_pos(QPointF()),
- target_viewport_pos(QPointF()),
- verticalScrollAnim(new QTimeLine(duration, this)),
+ target_scene_pos(),
+ target_viewport_pos(),
+ verticalScrollAnim(),
_numScheduledVerticalScrollings(0),
- horizontalScrollAnim(new QTimeLine(duration, this)),
+ horizontalScrollAnim(),
_numScheduledHorizontalScrollings(0)
{
_view->viewport()->installEventFilter(this);
_view->viewport()->grabGesture(Qt::PinchGesture);
_view->setMouseTracking(true);
- verticalScrollAnim->setUpdateInterval(updateInterval);
- connect(verticalScrollAnim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::VerticalScrollingTime);
- connect(verticalScrollAnim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished);
-
- horizontalScrollAnim->setUpdateInterval(updateInterval);
- connect(horizontalScrollAnim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::HorizontalScrollingTime);
- connect(horizontalScrollAnim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished);
+ InitScrollingAnimation();
}
//---------------------------------------------------------------------------------------------------------------------
@@ -186,6 +178,34 @@ void GraphicsViewZoom::set_zoom_factor_base(double value)
_zoom_factor_base = value;
}
+//---------------------------------------------------------------------------------------------------------------------
+void GraphicsViewZoom::InitScrollingAnimation()
+{
+ VSettings *settings = qobject_cast(qApp->Settings());
+
+ if (not verticalScrollAnim.isNull())
+ {
+ delete verticalScrollAnim;
+ }
+
+ verticalScrollAnim = new QTimeLine(settings->GetScrollingDuration(), this);
+ verticalScrollAnim->setUpdateInterval(settings->GetScrollingUpdateInterval());
+
+ connect(verticalScrollAnim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::VerticalScrollingTime);
+ connect(verticalScrollAnim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished);
+
+ if (not horizontalScrollAnim.isNull())
+ {
+ delete horizontalScrollAnim;
+ }
+
+ horizontalScrollAnim = new QTimeLine(settings->GetScrollingDuration(), this);
+ horizontalScrollAnim->setUpdateInterval(settings->GetScrollingUpdateInterval());
+
+ connect(horizontalScrollAnim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::HorizontalScrollingTime);
+ connect(horizontalScrollAnim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void GraphicsViewZoom::VerticalScrollingTime(qreal x)
{
@@ -490,6 +510,12 @@ void VMainGraphicsView::ZoomFitBest()
emit ScaleChanged(this->transform().m11());
}
+//---------------------------------------------------------------------------------------------------------------------
+void VMainGraphicsView::ResetScrollingAnimation()
+{
+ zoom->InitScrollingAnimation();
+}
+
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mousePressEvent handle mouse press events.
diff --git a/src/libs/vwidgets/vmaingraphicsview.h b/src/libs/vwidgets/vmaingraphicsview.h
index 81d2785c1..652fa0b30 100644
--- a/src/libs/vwidgets/vmaingraphicsview.h
+++ b/src/libs/vwidgets/vmaingraphicsview.h
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
/*!
* This class adds ability to zoom QGraphicsView using mouse wheel. The point under cursor
@@ -77,6 +78,7 @@ public:
void gentle_zoom(double factor);
void set_modifiers(Qt::KeyboardModifiers modifiers);
void set_zoom_factor_base(double value);
+ void InitScrollingAnimation();
signals:
void zoomed();
public slots:
@@ -92,16 +94,13 @@ private:
double _zoom_factor_base;
QPointF target_scene_pos;
QPointF target_viewport_pos;
- QTimeLine *verticalScrollAnim;
+ QPointer verticalScrollAnim;
/** @brief _numScheduledVerticalScrollings keep number scheduled vertical scrollings. */
qreal _numScheduledVerticalScrollings;
- QTimeLine *horizontalScrollAnim;
+ QPointer horizontalScrollAnim;
/** @brief _numScheduledHorizontalScrollings keep number scheduled horizontal scrollings. */
qreal _numScheduledHorizontalScrollings;
- static const int duration;
- static const int updateInterval;
-
void FictiveSceneRect(QGraphicsScene *sc, QGraphicsView *view);
void StartVerticalScrollings(QWheelEvent* wheel_event);
@@ -154,6 +153,7 @@ public slots:
void ZoomOut();
void ZoomOriginal();
void ZoomFitBest();
+ void ResetScrollingAnimation();
protected:
virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;