391 {
392
394 return 0;
395 }
396
397
398
400 const bool isLeftToRight = parentWidget()->isLeftToRight();
401
403
404 const int maxWidth = isVertical ?
rect.width() :
rect.height();
405
406 const int iconWidth = qMax(1, isVertical ?
iconSize.width() :
iconSize.height());
407 const int iconHeight = qMax(1, isVertical ?
iconSize.height() :
iconSize.width());
408
409 const Section::Separators separator =
m_compact ?
411 : isVertical ?
413 :
415
416 const int maxColumns = qMax(1, (maxWidth / iconWidth));
417
419 int offset = 0;
420 bool firstSection = true;
424 if (buttonCount == 0) {
425
426 if (notDryRun) {
427 section->setGeometry(1000, 1000, 0, 0);
428 }
429 continue;
430 }
431
432
433 const int onset =
m_compact ? offset : 0;
434 const int usedColumns = onset + buttonCount;
435 offset = usedColumns % maxColumns;
436
437
438 const int neededRowCount = ((usedColumns - 1) / maxColumns) + 1;
439
440 if (firstSection) {
441 firstSection = false;
442 } else {
444
445 y += (onset == 0) ? iconHeight : 0;
446 } else {
447
448 y += iconHeight + spacing();
449 }
450 if (notDryRun) {
453 }
454 }
455
456 if (notDryRun) {
457 const int onW = onset * iconWidth;
458 const int offW = offset * iconWidth;
459 const int width = maxColumns * iconWidth;
460 const int height = neededRowCount * iconHeight;
461
462 QRect geometry;
463 QRegion mask;
464 if (isVertical) {
465 mask = QRegion(0, 0, width, height);
466 if (isLeftToRight) {
467 geometry = QRect(0, y, width, height);
468
469
470
471 mask -= QRegion(0, 0, onW, iconHeight);
472 if (offset != 0) {
473 mask -= QRegion(offW, height - iconHeight, width - offW, iconHeight);
474 }
475 } else {
476 geometry = QRect(
rect.width() - width, y, width, height);
477 mask -= QRegion(width - onW, 0, onW, iconHeight);
478 if (offset != 0) {
479 mask -= QRegion(0, height - iconHeight, width - offW, iconHeight);
480 }
481 }
482 } else {
483 mask = QRegion(0, 0, height, width);
484 if (isLeftToRight) {
485 geometry = QRect(y, 0, height, width);
486 mask -= QRegion(0, 0, iconHeight, onW);
487 if (offset != 0) {
488 mask -= QRegion(height - iconHeight, offW, iconHeight, width - offW);
489 }
490 } else {
491 geometry = QRect(
rect.width() - y - height, 0, height, width);
492 mask -= QRegion(height - iconHeight, 0, iconHeight, onW);
493 if (offset != 0) {
494 mask -= QRegion(0, offW, iconHeight, width - offW);
495 }
496 }
497 }
498 section->setGeometry(geometry);
499 section->setMask(mask);
500 }
501
502
503 y += (neededRowCount - 1) * iconHeight;
504 }
505
506
507 return y + iconHeight;
508 }
int iconSize(qreal width, qreal height)
void setSeparator(Separators separators)
int visibleButtonCount() const