From da0dabc50d54677d547b6f62a49979f3b9d036c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 18 Jul 2016 15:08:42 +0100 Subject: [PATCH] Fix displaying resize widget with small number of sectors. --- src/gui/partresizerwidget.cpp | 10 +++++----- src/gui/partresizerwidget.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/partresizerwidget.cpp b/src/gui/partresizerwidget.cpp index 564f93d..4866050 100644 --- a/src/gui/partresizerwidget.cpp +++ b/src/gui/partresizerwidget.cpp @@ -133,10 +133,10 @@ qint32 PartResizerWidget::handleWidth() const return style()->pixelMetric(QStyle::PM_SplitterWidth); } -qint64 PartResizerWidget::sectorsPerPixel() const +long double PartResizerWidget::sectorsPerPixel() const { //FIXME: Make sure that this function never return 0 - return totalSectors() / (width() - 2 * handleWidth()); + return totalSectors() / (width() - 2.0L * handleWidth()); } int PartResizerWidget::partWidgetStart() const @@ -286,13 +286,13 @@ void PartResizerWidget::mouseMoveEvent(QMouseEvent* event) int x = event->pos().x() - m_Hotspot; if (draggedWidget() == &leftHandle()) { - const qint64 newFirstSector = qMax(minimumFirstSector() + x * sectorsPerPixel(), 0LL); + const qint64 newFirstSector = qMax(minimumFirstSector() + x * sectorsPerPixel(), 0.0L); updateFirstSector(newFirstSector); } else if (draggedWidget() == &rightHandle()) { - const qint64 newLastSector = qMin(minimumFirstSector() + (x - rightHandle().width()) * sectorsPerPixel(), maximumLastSector()); + const qint64 newLastSector = qMin(static_cast(minimumFirstSector() + (x - rightHandle().width()) * sectorsPerPixel()), maximumLastSector()); updateLastSector(newLastSector); } else if (draggedWidget() == &partWidget() && moveAllowed()) { - const qint64 newFirstSector = qMax(minimumFirstSector() + (x - handleWidth()) * sectorsPerPixel(), 0LL); + const qint64 newFirstSector = qMax(minimumFirstSector() + (x - handleWidth()) * sectorsPerPixel(), 0.0L); movePartition(newFirstSector); } } diff --git a/src/gui/partresizerwidget.h b/src/gui/partresizerwidget.h index 11b84a1..fc8e2b0 100644 --- a/src/gui/partresizerwidget.h +++ b/src/gui/partresizerwidget.h @@ -169,7 +169,7 @@ protected: return m_RightHandle; } - qint64 sectorsPerPixel() const; + long double sectorsPerPixel() const; void set(qint64 newCap, qint64 newFreeBefore, qint64 newFreeAfter);