From 98e59d96b73580f588165ff0248092a11b9f90ab Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 26 Oct 2022 21:43:08 +0530 Subject: [PATCH] For some reason the splitters are wider in the editor/viewer than in the main GUI so use the actual splitterhandle pixel metric to draw the dots otherwise they look too large --- .../gui2/progress_indicator/QProgressIndicator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp b/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp index c87f5fcd58..8866078315 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp @@ -346,10 +346,14 @@ void CalibreStyle::drawControl(ControlElement element, const QStyleOption *optio painter->setBrush(option->palette.color(QPalette::ColorGroup::Normal, QPalette::ColorRole::Shadow)); bool horizontal = (option->state & QStyle::State_Horizontal) ? true : false; static const int dot_count = 4; - int handle_width = horizontal ? option->rect.width() : option->rect.height(); - int dot_size = std::max(1, handle_width); - int start_point = (horizontal ? option->rect.height()/2 : option->rect.width()/2) - (dot_count*dot_size/2); + const int handle_width = pixelMetric(PM_SplitterWidth, option, widget); + const int available_diameter = horizontal ? option->rect.width() : option->rect.height(); + const int dot_size = std::max(1, std::min(handle_width, available_diameter)); + const int start_point = (horizontal ? option->rect.height()/2 : option->rect.width()/2) - (dot_count*dot_size/2); + const int offset = (available_diameter - dot_size) / 2; QRect dot_rect = QRect(option->rect.left(), option->rect.top(), dot_size, dot_size); + if (horizontal) dot_rect.moveLeft(dot_rect.left() + offset); + else dot_rect.moveTop(dot_rect.top() + offset); for (int i = 0; i < dot_count; i++) { // Move the rect to leave spaces between the dots if (horizontal) dot_rect.moveTop(option->rect.top() + start_point + i*dot_size*2);