mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
DRYer
This commit is contained in:
parent
cac7d37d50
commit
45f82b9676
@ -344,16 +344,16 @@ void CalibreStyle::drawControl(ControlElement element, const QStyleOption *optio
|
|||||||
painter->drawRect(option->rect);
|
painter->drawRect(option->rect);
|
||||||
// draw the dots
|
// draw the dots
|
||||||
painter->setBrush(option->palette.color(QPalette::ColorGroup::Normal, QPalette::ColorRole::Shadow));
|
painter->setBrush(option->palette.color(QPalette::ColorGroup::Normal, QPalette::ColorRole::Shadow));
|
||||||
bool horizontal = option->state & QStyle::State_Horizontal ? true : false;
|
bool horizontal = (option->state & QStyle::State_Horizontal) ? true : false;
|
||||||
static const int dot_count = 4;
|
static const int dot_count = 4;
|
||||||
int handle_width = horizontal ? option->rect.width() : option->rect.height();
|
int handle_width = horizontal ? option->rect.width() : option->rect.height();
|
||||||
int dot_size = std::max(1, handle_width);
|
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);
|
int start_point = (horizontal ? option->rect.height()/2 : option->rect.width()/2) - (dot_count*dot_size/2);
|
||||||
QRect dot_rect;
|
QRect dot_rect = QRect(option->rect.left(), option->rect.top(), dot_size, dot_size);
|
||||||
for (int i = 0; i < dot_count; i++) {
|
for (int i = 0; i < dot_count; i++) {
|
||||||
// Move the rect to leave spaces between the dots
|
// Move the rect to leave spaces between the dots
|
||||||
if (horizontal) dot_rect = QRect(0, start_point + i*dot_size*2, dot_size, dot_size);
|
if (horizontal) dot_rect.moveTop(option->rect.top() + start_point + i*dot_size*2);
|
||||||
else dot_rect = QRect(start_point + i*dot_size*2, 0, dot_size, dot_size);
|
else dot_rect.moveLeft(option->rect.left() + start_point + i*dot_size*2);
|
||||||
painter->drawEllipse(dot_rect);
|
painter->drawEllipse(dot_rect);
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user