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

This commit is contained in:
Kovid Goyal 2022-10-26 21:43:08 +05:30
parent 45f82b9676
commit 98e59d96b7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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);